Feat: commit antes de mostrar el codigo.
- Añadido alta propiedad - Arreglado alta inq/prop - Añadida pantalla de menu
This commit is contained in:
@@ -26,13 +26,13 @@ public class InquilinoController: ControllerBase
|
||||
|
||||
[HttpPost("api/inquilino")]
|
||||
public IActionResult Post([FromBody] CrearClienteDto cid, [FromHeader(Name = "Auth")] string Auth) {
|
||||
if (!string.IsNullOrEmpty(Auth)) return BadRequest();
|
||||
if (string.IsNullOrEmpty(Auth)) return BadRequest(new {message = "El String Auth Esta Vacio"});
|
||||
var ret3 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 4);
|
||||
if (ret3 == false) return BadRequest(ret3);
|
||||
if (ret3 == false) return BadRequest(new {message = "Falló el permiso"});
|
||||
|
||||
|
||||
var ret = verificarCrearUsuario(cid);
|
||||
if (ret != "") return BadRequest(ret);
|
||||
if (ret != "") return BadRequest(new {message = ret});
|
||||
|
||||
var cli = new Cliente {
|
||||
Dni = cid.dni,
|
||||
@@ -45,7 +45,7 @@ public class InquilinoController: ControllerBase
|
||||
};
|
||||
|
||||
bool ret2 = RepositorioUsuarios.Singleton.AltaInquilino(cli);
|
||||
return (ret2) ? Ok() : BadRequest(ret);
|
||||
return (ret2) ? Ok(new {message = "Se dio de alta la cuenta"}) : BadRequest(new {message = "Fallo Dar de Alta El inquilino"});
|
||||
}
|
||||
|
||||
private string verificarCrearUsuario(CrearClienteDto cid) {
|
||||
|
||||
@@ -24,10 +24,10 @@ public class PropiedadesController: ControllerBase {
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (Id < 0) return BadRequest("la id de propiedad no puede ser negativa");
|
||||
if (Id < 0) return BadRequest(new {message ="la id de propiedad no puede ser negativa"});
|
||||
|
||||
var ret = RepositorioPropiedades.Singleton.ObtenerPropiedadPorId(Id);
|
||||
if (ret == null) return BadRequest("No existe la propiedad");
|
||||
if (ret == null) return BadRequest(new {message ="No existe la propiedad"});
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class PropiedadesController: ControllerBase {
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
email = email.Trim();
|
||||
if (String.IsNullOrEmpty(email)) return BadRequest("falta campo email");
|
||||
if (String.IsNullOrEmpty(email)) return BadRequest(new {message ="falta campo email"});
|
||||
|
||||
var ret = RepositorioPropiedades.Singleton.ObtenerPropiedadesPorEmail(email);
|
||||
|
||||
@@ -58,21 +58,21 @@ public class PropiedadesController: ControllerBase {
|
||||
if (validacion2 != "") return BadRequest(new { message = validacion2 });
|
||||
|
||||
Cliente? cli = RepositorioPropietario.Singleton.ObtenerPropietarioPorEmail(propiedad.Email);
|
||||
if (cli == null) return BadRequest("El email no corresponde a un propietario");
|
||||
if (cli == null) return BadRequest(new { message = "El email no corresponde a un propietario"});
|
||||
|
||||
Propiedade Prop = new Propiedade{
|
||||
Canthabitaciones = propiedad.Canthabitaciones,
|
||||
Dnipropietario = cli.Dni,
|
||||
Idtipropiedad = propiedad.Idtipropiedad,
|
||||
Ubicacion = propiedad.Ubicacion,
|
||||
Letra = propiedad.Letra != null ? propiedad.Letra : null,
|
||||
Piso = propiedad.Piso != null ? propiedad.Piso : null,
|
||||
Letra = propiedad.Letra ?? null,
|
||||
Piso = propiedad.Piso ?? null,
|
||||
};
|
||||
|
||||
var ret = RepositorioPropiedades.Singleton.AñadirPropiedad(Prop);
|
||||
return (ret)?
|
||||
Ok("Fue Cargado Correctamente") :
|
||||
BadRequest("Fallo al momento de añadir la propiedad a la base de datos");
|
||||
Ok(new { message = "Fue Cargado Correctamente"}) :
|
||||
BadRequest(new { message = "Fallo al momento de añadir la propiedad a la base de datos"});
|
||||
}
|
||||
|
||||
[HttpDelete("api/propiedad")]
|
||||
@@ -81,13 +81,13 @@ public class PropiedadesController: ControllerBase {
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (id <= 0) return BadRequest("No es una id valida");
|
||||
if (id <= 0) return BadRequest(new { message = "No es una id valida"});
|
||||
|
||||
var ret = RepositorioPropiedades.Singleton.BajaPropiedad(id);
|
||||
|
||||
return ret ?
|
||||
Ok(new {message = $"la propiedad con id {id} fue dada de baja"}):
|
||||
BadRequest("Fallo al dar de baja la propiedad");
|
||||
BadRequest(new {message="Fallo al dar de baja la propiedad"});
|
||||
}
|
||||
|
||||
[HttpPut("api/propiedades/addServicio")]
|
||||
@@ -96,21 +96,21 @@ public class PropiedadesController: ControllerBase {
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 8);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (Servicios.propiedadid <= 0) return BadRequest("No puede tener una id negativa o cero");
|
||||
if (Servicios.idServicios.Count() < 1) return BadRequest("Falta añadir servicios");
|
||||
if (Servicios.idServicios.Any(x => x<= 0)) return BadRequest("No tienen haber ids negativas o cero de servicio");
|
||||
if (Servicios.propiedadid <= 0) return BadRequest(new {message ="No puede tener una id negativa o cero"});
|
||||
if (Servicios.idServicios.Count() < 1) return BadRequest(new {message ="Falta añadir servicios"});
|
||||
if (Servicios.idServicios.Any(x => x<= 0)) return BadRequest(new {message ="No tienen haber ids negativas o cero de servicio"});
|
||||
|
||||
var serv = RepositorioServicios.Singleton.ObtenerServiciosPorPropiedad(Servicios.propiedadid);
|
||||
|
||||
bool validacion2 = Servicios.idServicios.Any(x => serv.Contains(x));
|
||||
|
||||
if (validacion2 == true) return BadRequest("Hay elementos repetidos");
|
||||
if (validacion2 == true) return BadRequest(new {message ="Hay elementos repetidos"});
|
||||
|
||||
bool ret = RepositorioPropiedades.
|
||||
Singleton.AñadirServicioAPropiedad(Servicios.propiedadid, Servicios.idServicios);
|
||||
|
||||
return ret ?
|
||||
Ok("Los Servicios Se Cargaron correctamente a la propiedad") : BadRequest("No se pudo Cargar los Servicios a la propiedad");
|
||||
Ok(new {message ="Los Servicios Se Cargaron correctamente a la propiedad"}) : BadRequest(new {message ="No se pudo Cargar los Servicios a la propiedad"});
|
||||
|
||||
}
|
||||
|
||||
@@ -120,9 +120,9 @@ public class PropiedadesController: ControllerBase {
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 13);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (servicio.propiedadid <= 0) return BadRequest("No puede tener una id negativa o cero");
|
||||
if (servicio.idServicios.Count() < 1) return BadRequest("Falta añadir servicios");
|
||||
if (servicio.idServicios.Any(x => x<= 0)) return BadRequest("No tienen haber ids negativas o cero de servicio");
|
||||
if (servicio.propiedadid <= 0) return BadRequest(new {message ="No puede tener una id negativa o cero"});
|
||||
if (servicio.idServicios.Count() < 1) return BadRequest(new {message ="Falta añadir servicios"});
|
||||
if (servicio.idServicios.Any(x => x<= 0)) return BadRequest(new {message ="No tienen haber ids negativas o cero de servicio"});
|
||||
|
||||
var serv = RepositorioServicios.Singleton.ObtenerServiciosPorPropiedad(servicio.propiedadid);
|
||||
|
||||
@@ -131,7 +131,7 @@ public class PropiedadesController: ControllerBase {
|
||||
bool ret = RepositorioPropiedades.Singleton.BajaServiciosAPropiedad(servicio.propiedadid, servicio.idServicios);
|
||||
|
||||
return ret ?
|
||||
Ok("Se Eliminaron los servicios seleccionados de la propiedad") : BadRequest("Fallo al eliminarse los servicios de la propiedad");
|
||||
Ok(new {message ="Se Eliminaron los servicios seleccionados de la propiedad"}) : BadRequest(new {message ="Fallo al eliminarse los servicios de la propiedad"});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class PropietarioController: ControllerBase {
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpPost("api/propietarios")]
|
||||
[HttpPost("api/propietario")]
|
||||
public IActionResult AltaPropietario([FromBody]CrearClienteDto Propietario,
|
||||
[FromHeader(Name = "Auth")] string Auth) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
|
||||
Reference in New Issue
Block a user