Avansamos mucho con el administracion propiedades
This commit is contained in:
@@ -8,20 +8,27 @@ namespace AlquilaFacil.Controllers;
|
||||
[ApiController]
|
||||
public class PropiedadesController: ControllerBase {
|
||||
[HttpGet("api/propiedades")]
|
||||
public IActionResult ListarPropiedades([FromHeader(Name = "Auth")] string Auth) {
|
||||
public IActionResult ListarPropiedades([FromHeader(Name = "Auth")] string Auth, int pag = 0) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
||||
if (validacion1 == false) validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
var ret = RepositorioPropiedades.Singleton.ListarPropiedades();
|
||||
IQueryable<PropiedadesDto> ret;
|
||||
|
||||
if (pag == 0){
|
||||
ret = RepositorioPropiedades.Singleton.ListarPropiedades();
|
||||
} else{
|
||||
ret = RepositorioPropiedades.Singleton.ListarPropiedadesPorPagina(pag);
|
||||
}
|
||||
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpGet("api/propiedad")]
|
||||
public IActionResult ObtenerPropiedadPorId(int Id, [FromHeader(Name = "Auth")] string Auth) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (Id < 0) return BadRequest(new {message ="la id de propiedad no puede ser negativa"});
|
||||
@@ -31,6 +38,25 @@ public class PropiedadesController: ControllerBase {
|
||||
return Ok(ret);
|
||||
}
|
||||
|
||||
[HttpGet("api/propiedad/cantPagina")]
|
||||
public IActionResult ObtenerCantidadDePaginas([FromHeader(Name = "Auth")] string Auth, int estado = 0) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (estado < 0) return BadRequest(new {message = "No puede tener un numero menor a 0"});
|
||||
int cant;
|
||||
|
||||
if(estado == 0){
|
||||
cant = RepositorioPropiedades.Singleton.CuantasPaginas();
|
||||
}else{
|
||||
cant = RepositorioPropiedades.Singleton.CuantasPaginas(estado);
|
||||
}
|
||||
|
||||
return Ok(new {message = cant});
|
||||
|
||||
}
|
||||
|
||||
[HttpGet("api/propiedades/Propietario")]
|
||||
public IActionResult ObtenerPropiedadesPorPropietario (
|
||||
[FromHeader(Name = "Email")] string email,
|
||||
|
||||
Reference in New Issue
Block a user