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