Replace RepositorioGrupos with RepositorioPermisos
This commit is contained in:
@@ -7,17 +7,21 @@ using Modelo;
|
|||||||
namespace AlquilaFacil.Controllers;
|
namespace AlquilaFacil.Controllers;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class DefectoController: ControllerBase {
|
public class DefectoController : ControllerBase
|
||||||
|
{
|
||||||
|
|
||||||
[HttpGet("api/defectos")]
|
[HttpGet("api/defectos")]
|
||||||
public IActionResult ObtenerDefectosEnContrato([FromHeader(Name = "Auth")] string Auth, long Idcontrato = 0) {
|
public IActionResult ObtenerDefectosEnContrato([FromHeader(Name = "Auth")] string Auth, long Idcontrato = 0)
|
||||||
|
{
|
||||||
if (Idcontrato <= 0) return BadRequest(new { message = "La id de contrato no puede ser menor o igual a 0" });
|
if (Idcontrato <= 0) return BadRequest(new { message = "La id de contrato no puede ser menor o igual a 0" });
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||||
if (validacion1 == false){
|
if (validacion1 == false)
|
||||||
validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
{
|
||||||
if (validacion1 == false) {
|
validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 11);
|
||||||
|
if (validacion1 == false)
|
||||||
|
{
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,7 +36,8 @@ public class DefectoController: ControllerBase {
|
|||||||
|
|
||||||
var l = RepositorioDefectos.Singleton.ObtenerDefectosPorIdContrato(Idcontrato);
|
var l = RepositorioDefectos.Singleton.ObtenerDefectosPorIdContrato(Idcontrato);
|
||||||
List<DefectoDto> ll = new();
|
List<DefectoDto> ll = new();
|
||||||
foreach (var i in l){
|
foreach (var i in l)
|
||||||
|
{
|
||||||
var n = new DefectoDtoBuilder()
|
var n = new DefectoDtoBuilder()
|
||||||
.SetId(i.Id)
|
.SetId(i.Id)
|
||||||
.SetDesc(i.Descripcion)
|
.SetDesc(i.Descripcion)
|
||||||
@@ -48,9 +53,10 @@ public class DefectoController: ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("api/defecto")]
|
[HttpPost("api/defecto")]
|
||||||
public IActionResult AltaDefecto([FromHeader(Name = "Auth")] string Auth, AltaDefectoDto data) {
|
public IActionResult AltaDefecto([FromHeader(Name = "Auth")] string Auth, AltaDefectoDto data)
|
||||||
|
{
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 11);
|
||||||
if (validacion1 == false) return Unauthorized();
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
@@ -59,7 +65,8 @@ public class DefectoController: ControllerBase {
|
|||||||
string r = ValidarDto(data);
|
string r = ValidarDto(data);
|
||||||
if (r != "") return BadRequest(new { message = r });
|
if (r != "") return BadRequest(new { message = r });
|
||||||
|
|
||||||
Defecto defecto = new Defecto{
|
Defecto defecto = new Defecto
|
||||||
|
{
|
||||||
Costo = data.Costo,
|
Costo = data.Costo,
|
||||||
Descripcion = data.Descripcion,
|
Descripcion = data.Descripcion,
|
||||||
Idcontrato = data.Idcontrato,
|
Idcontrato = data.Idcontrato,
|
||||||
@@ -72,7 +79,8 @@ public class DefectoController: ControllerBase {
|
|||||||
return b ? Ok(new { message = "Se cargo el Defecto en el sistema" }) : BadRequest(new { message = "No se pudo cargar el defecto en el sistema" });
|
return b ? Ok(new { message = "Se cargo el Defecto en el sistema" }) : BadRequest(new { message = "No se pudo cargar el defecto en el sistema" });
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ValidarDto(AltaDefectoDto d){
|
private string ValidarDto(AltaDefectoDto d)
|
||||||
|
{
|
||||||
string ret = "";
|
string ret = "";
|
||||||
|
|
||||||
if (d == null) return "Dto nulo";
|
if (d == null) return "Dto nulo";
|
||||||
@@ -84,9 +92,10 @@ public class DefectoController: ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("api/defecto/marcarpago")]
|
[HttpPut("api/defecto/marcarpago")]
|
||||||
public IActionResult MarcarPago([FromHeader(Name = "Auth")] string Auth, long iddefecto = 0) {
|
public IActionResult MarcarPago([FromHeader(Name = "Auth")] string Auth, long iddefecto = 0)
|
||||||
|
{
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 12);
|
||||||
if (validacion1 == false) return Unauthorized();
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
|||||||
Reference in New Issue
Block a user