ahi le cambie los checkgrupo por checkpermiso
This commit is contained in:
@@ -6,9 +6,11 @@ using Modelo;
|
|||||||
namespace AlquilaFacil.Controllers;
|
namespace AlquilaFacil.Controllers;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class PropiedadesController: ControllerBase {
|
public class PropiedadesController : ControllerBase
|
||||||
|
{
|
||||||
[HttpGet("api/propiedades")]
|
[HttpGet("api/propiedades")]
|
||||||
public IActionResult ListarPropiedades([FromHeader(Name = "Auth")] string Auth, int pag = 0) {
|
public IActionResult ListarPropiedades([FromHeader(Name = "Auth")] string Auth, int pag = 0)
|
||||||
|
{
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
||||||
if (validacion1 == false) validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
if (validacion1 == false) validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||||
@@ -16,9 +18,12 @@ public class PropiedadesController: ControllerBase {
|
|||||||
|
|
||||||
IQueryable<PropiedadesDto> ret;
|
IQueryable<PropiedadesDto> ret;
|
||||||
|
|
||||||
if (pag == 0){
|
if (pag == 0)
|
||||||
|
{
|
||||||
ret = RepositorioPropiedades.Singleton.ListarPropiedades();
|
ret = RepositorioPropiedades.Singleton.ListarPropiedades();
|
||||||
} else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
ret = RepositorioPropiedades.Singleton.ListarPropiedadesPorPagina(pag);
|
ret = RepositorioPropiedades.Singleton.ListarPropiedadesPorPagina(pag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,9 +31,11 @@ public class PropiedadesController: ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("/api/propiedades/Venta")]
|
[HttpGet("/api/propiedades/Venta")]
|
||||||
public IActionResult ObtenerPropiedadesParaVenta([FromHeader(Name = "Auth")] string Auth, int pag = 0) {
|
public IActionResult ObtenerPropiedadesParaVenta([FromHeader(Name = "Auth")] string Auth, int pag = 0)
|
||||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
{
|
||||||
if (validacion1 == false) {
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 16);
|
||||||
|
if (validacion1 == false)
|
||||||
|
{
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,8 +48,10 @@ public class PropiedadesController: ControllerBase {
|
|||||||
|
|
||||||
List<PropiedadesVentaDto> l = new();
|
List<PropiedadesVentaDto> l = new();
|
||||||
|
|
||||||
foreach (var i in props) {
|
foreach (var i in props)
|
||||||
var p = new PropiedadesVentaDto{
|
{
|
||||||
|
var p = new PropiedadesVentaDto
|
||||||
|
{
|
||||||
Id = i.Id,
|
Id = i.Id,
|
||||||
Ubicacion = i.Ubicacion,
|
Ubicacion = i.Ubicacion,
|
||||||
Canthabitaciones = i.Canthabitaciones,
|
Canthabitaciones = i.Canthabitaciones,
|
||||||
@@ -62,9 +71,11 @@ public class PropiedadesController: ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("api/propiedades/Venta/Propietario")]
|
[HttpGet("api/propiedades/Venta/Propietario")]
|
||||||
public IActionResult ObtenerPropiedadesVentaDePropietario( [FromHeader(Name = "Auth")] string Auth){
|
public IActionResult ObtenerPropiedadesVentaDePropietario([FromHeader(Name = "Auth")] string Auth)
|
||||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
{
|
||||||
if (validacion1 == false) {
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 15);
|
||||||
|
if (validacion1 == false)
|
||||||
|
{
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,8 +85,10 @@ public class PropiedadesController: ControllerBase {
|
|||||||
var props = RepositorioPropiedades.Singleton.ObtenerPropiedadesAVentaPorDni(cli.Dni);
|
var props = RepositorioPropiedades.Singleton.ObtenerPropiedadesAVentaPorDni(cli.Dni);
|
||||||
List<PropiedadesDto> ll = new();
|
List<PropiedadesDto> ll = new();
|
||||||
|
|
||||||
foreach (var i in props) {
|
foreach (var i in props)
|
||||||
var a = new PropiedadesDto {
|
{
|
||||||
|
var a = new PropiedadesDto
|
||||||
|
{
|
||||||
id = i.Id,
|
id = i.Id,
|
||||||
Ubicacion = i.Ubicacion,
|
Ubicacion = i.Ubicacion,
|
||||||
canthabitaciones = i.Canthabitaciones,
|
canthabitaciones = i.Canthabitaciones,
|
||||||
@@ -92,7 +105,8 @@ public class PropiedadesController: ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("api/propiedad")]
|
[HttpGet("api/propiedad")]
|
||||||
public IActionResult ObtenerPropiedadPorId(int Id, [FromHeader(Name = "Auth")] string Auth) {
|
public IActionResult ObtenerPropiedadPorId(int Id, [FromHeader(Name = "Auth")] string Auth)
|
||||||
|
{
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
||||||
if (validacion1 == false) return Unauthorized();
|
if (validacion1 == false) return Unauthorized();
|
||||||
@@ -105,7 +119,8 @@ public class PropiedadesController: ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("api/propiedad/cantPagina")]
|
[HttpGet("api/propiedad/cantPagina")]
|
||||||
public IActionResult ObtenerCantidadDePaginas([FromHeader(Name = "Auth")] string Auth, int estado = 0) {
|
public IActionResult ObtenerCantidadDePaginas([FromHeader(Name = "Auth")] string Auth, int estado = 0)
|
||||||
|
{
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 10);
|
||||||
if (validacion1 == false) return Unauthorized();
|
if (validacion1 == false) return Unauthorized();
|
||||||
@@ -113,9 +128,12 @@ public class PropiedadesController: ControllerBase {
|
|||||||
if (estado < 0) return BadRequest(new { message = "No puede tener un numero menor a 0" });
|
if (estado < 0) return BadRequest(new { message = "No puede tener un numero menor a 0" });
|
||||||
int cant;
|
int cant;
|
||||||
|
|
||||||
if(estado == 0){
|
if (estado == 0)
|
||||||
|
{
|
||||||
cant = RepositorioPropiedades.Singleton.CuantasPaginas();
|
cant = RepositorioPropiedades.Singleton.CuantasPaginas();
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
cant = RepositorioPropiedades.Singleton.CuantasPaginas(estado);
|
cant = RepositorioPropiedades.Singleton.CuantasPaginas(estado);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +144,8 @@ public class PropiedadesController: ControllerBase {
|
|||||||
[HttpGet("api/propiedades/Propietario")]
|
[HttpGet("api/propiedades/Propietario")]
|
||||||
public IActionResult ObtenerPropiedadesPorPropietario(
|
public IActionResult ObtenerPropiedadesPorPropietario(
|
||||||
[FromHeader(Name = "Email")] string email,
|
[FromHeader(Name = "Email")] string email,
|
||||||
[FromHeader(Name = "Auth")] string Auth) {
|
[FromHeader(Name = "Auth")] string Auth)
|
||||||
|
{
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||||
@@ -142,7 +161,8 @@ public class PropiedadesController: ControllerBase {
|
|||||||
[HttpGet("api/propiedades/Propietario/Bajas")]
|
[HttpGet("api/propiedades/Propietario/Bajas")]
|
||||||
public IActionResult ObtenerPropiedadesPorPropietarioBajas(
|
public IActionResult ObtenerPropiedadesPorPropietarioBajas(
|
||||||
[FromHeader(Name = "Email")] string email,
|
[FromHeader(Name = "Email")] string email,
|
||||||
[FromHeader(Name = "Auth")] string Auth) {
|
[FromHeader(Name = "Auth")] string Auth)
|
||||||
|
{
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 8);
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 8);
|
||||||
@@ -156,7 +176,8 @@ public class PropiedadesController: ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("api/propiedad")]
|
[HttpPost("api/propiedad")]
|
||||||
public IActionResult AltaPropiedad([FromBody] AltaPropiedadDto propiedad, [FromHeader(Name = "Auth")] string Auth) {
|
public IActionResult AltaPropiedad([FromBody] AltaPropiedadDto propiedad, [FromHeader(Name = "Auth")] string Auth)
|
||||||
|
{
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 1);
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 1);
|
||||||
if (validacion1 == false) return Unauthorized();
|
if (validacion1 == false) return Unauthorized();
|
||||||
@@ -167,7 +188,8 @@ public class PropiedadesController: ControllerBase {
|
|||||||
Cliente? cli = RepositorioPropietario.Singleton.ObtenerPropietarioPorEmail(propiedad.Email);
|
Cliente? cli = RepositorioPropietario.Singleton.ObtenerPropietarioPorEmail(propiedad.Email);
|
||||||
if (cli == null) return BadRequest(new { message = "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{
|
Propiedade Prop = new Propiedade
|
||||||
|
{
|
||||||
Canthabitaciones = propiedad.Canthabitaciones,
|
Canthabitaciones = propiedad.Canthabitaciones,
|
||||||
Dnipropietario = cli.Dni,
|
Dnipropietario = cli.Dni,
|
||||||
Idtipropiedad = propiedad.Idtipropiedad,
|
Idtipropiedad = propiedad.Idtipropiedad,
|
||||||
@@ -185,7 +207,8 @@ public class PropiedadesController: ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPatch("api/propiedad")]
|
[HttpPatch("api/propiedad")]
|
||||||
public IActionResult PatchPropiedad([FromBody] PatchPropiedadDto propiedad, [FromHeader(Name = "Auth")] string Auth) {
|
public IActionResult PatchPropiedad([FromBody] PatchPropiedadDto propiedad, [FromHeader(Name = "Auth")] string Auth)
|
||||||
|
{
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||||
@@ -199,7 +222,8 @@ public class PropiedadesController: ControllerBase {
|
|||||||
|
|
||||||
List<Servicio> servs = RepositorioServicios.Singleton.ObtenerServiciosPorDescripcion(propiedad.Servicios);
|
List<Servicio> servs = RepositorioServicios.Singleton.ObtenerServiciosPorDescripcion(propiedad.Servicios);
|
||||||
|
|
||||||
Propiedade Prop = new Propiedade{
|
Propiedade Prop = new Propiedade
|
||||||
|
{
|
||||||
Id = propiedad.id,
|
Id = propiedad.id,
|
||||||
Canthabitaciones = propiedad.Canthabitaciones,
|
Canthabitaciones = propiedad.Canthabitaciones,
|
||||||
Dnipropietario = cli.Dni,
|
Dnipropietario = cli.Dni,
|
||||||
@@ -219,7 +243,8 @@ public class PropiedadesController: ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("api/propiedad")]
|
[HttpDelete("api/propiedad")]
|
||||||
public IActionResult BajaPropiedad(int id, [FromHeader(Name = "Auth")] string Auth, [FromHeader(Name = "Email")] string email){
|
public IActionResult BajaPropiedad(int id, [FromHeader(Name = "Auth")] string Auth, [FromHeader(Name = "Email")] string email)
|
||||||
|
{
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||||
if (validacion1 == false) return Unauthorized();
|
if (validacion1 == false) return Unauthorized();
|
||||||
@@ -236,7 +261,8 @@ public class PropiedadesController: ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("api/propiedades/addServicio")]
|
[HttpPut("api/propiedades/addServicio")]
|
||||||
public IActionResult AñadirServicio([FromBody] ServicioAPropiedadDto Servicios, [FromHeader(Name = "Auth")] string Auth) {
|
public IActionResult AñadirServicio([FromBody] ServicioAPropiedadDto Servicios, [FromHeader(Name = "Auth")] string Auth)
|
||||||
|
{
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||||
if (validacion1 == false) return Unauthorized();
|
if (validacion1 == false) return Unauthorized();
|
||||||
@@ -260,7 +286,8 @@ public class PropiedadesController: ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("api/propiedades/RmServicio")]
|
[HttpPut("api/propiedades/RmServicio")]
|
||||||
public IActionResult EliminarServicio([FromBody] ServicioAPropiedadDto servicio, [FromHeader(Name = "Auth")] string Auth) {
|
public IActionResult EliminarServicio([FromBody] ServicioAPropiedadDto servicio, [FromHeader(Name = "Auth")] string Auth)
|
||||||
|
{
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 2);
|
||||||
if (validacion1 == false) return Unauthorized();
|
if (validacion1 == false) return Unauthorized();
|
||||||
@@ -282,7 +309,8 @@ public class PropiedadesController: ControllerBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ValidarPropiedad(AltaPropiedadDto prop) {
|
private string ValidarPropiedad(AltaPropiedadDto prop)
|
||||||
|
{
|
||||||
if (prop == null) return "Esta mal formado el body de la request";
|
if (prop == null) return "Esta mal formado el body de la request";
|
||||||
|
|
||||||
string ret = "";
|
string ret = "";
|
||||||
@@ -301,7 +329,8 @@ public class PropiedadesController: ControllerBase {
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
private string ValidarPropiedad(PatchPropiedadDto prop) {
|
private string ValidarPropiedad(PatchPropiedadDto prop)
|
||||||
|
{
|
||||||
if (prop == null) return "Esta mal formado el body de la request";
|
if (prop == null) return "Esta mal formado el body de la request";
|
||||||
|
|
||||||
string ret = "";
|
string ret = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user