eliminado checkgrupos en notificaciones controller

This commit is contained in:
2025-04-28 17:27:02 -03:00
parent 0961618e40
commit 6926221353
+22 -14
View File
@@ -7,9 +7,11 @@ using Modelo;
namespace AlquilaFacil.Controllers; namespace AlquilaFacil.Controllers;
[ApiController] [ApiController]
public class NotificacionesController: ControllerBase { public class NotificacionesController : ControllerBase
{
[HttpGet("api/notificaciones")] [HttpGet("api/notificaciones")]
public IActionResult GetNotificaciones([FromHeader(Name ="Auth")]string Auth, bool leido = false) { public IActionResult GetNotificaciones([FromHeader(Name = "Auth")] string Auth, bool leido = false)
{
if (string.IsNullOrEmpty(Auth)) return Unauthorized(); if (string.IsNullOrEmpty(Auth)) return Unauthorized();
var cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth); var cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
@@ -20,7 +22,8 @@ public class NotificacionesController: ControllerBase {
List<NotificacionDto> noti = new(); List<NotificacionDto> noti = new();
foreach (Notificacione i in notificaciones) { foreach (Notificacione i in notificaciones)
{
if (i.DniclienteNavigation == null || i.DniremitenteNavigation == null) return BadRequest(new { message = "Esta mal cargado el precontrato" }); if (i.DniclienteNavigation == null || i.DniremitenteNavigation == null) return BadRequest(new { message = "Esta mal cargado el precontrato" });
var dto = new NotificacionDtoBuilder() var dto = new NotificacionDtoBuilder()
.SetRemitente(i.DniremitenteNavigation.Email ?? "") .SetRemitente(i.DniremitenteNavigation.Email ?? "")
@@ -38,7 +41,8 @@ public class NotificacionesController: ControllerBase {
} }
[HttpGet("api/notificaciones/haySinLeer")] [HttpGet("api/notificaciones/haySinLeer")]
public IActionResult GetHayNotis([FromHeader(Name ="Auth")]string Auth) { public IActionResult GetHayNotis([FromHeader(Name = "Auth")] string Auth)
{
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized(); if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized();
var cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth); var cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
@@ -49,7 +53,8 @@ public class NotificacionesController: ControllerBase {
} }
[HttpPut("api/notificaciones")] [HttpPut("api/notificaciones")]
public IActionResult MarcarComoLeido([FromHeader(Name = "Auth")]string Auth, NotificacionMarcarLeidoDto nota) { public IActionResult MarcarComoLeido([FromHeader(Name = "Auth")] string Auth, NotificacionMarcarLeidoDto nota)
{
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized(); if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized();
if (nota.Fecha == null || String.IsNullOrWhiteSpace(nota.Email)) return BadRequest(new { message = "Faltan datos" }); if (nota.Fecha == null || String.IsNullOrWhiteSpace(nota.Email)) return BadRequest(new { message = "Faltan datos" });
@@ -66,7 +71,8 @@ public class NotificacionesController: ControllerBase {
} }
[HttpPost("api/notificaciones/consultaAlquiler")] [HttpPost("api/notificaciones/consultaAlquiler")]
public IActionResult ConsultaAlquiler([FromHeader(Name ="Auth")]string Auth, [FromBody] AltaNotificacionDto data) { public IActionResult ConsultaAlquiler([FromHeader(Name = "Auth")] string Auth, [FromBody] AltaNotificacionDto data)
{
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized(); if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized();
bool validacion1 = RepositorioUsuarios.Singleton.CheckToken(data.Remitente, Auth); bool validacion1 = RepositorioUsuarios.Singleton.CheckToken(data.Remitente, Auth);
if (validacion1 == false) return BadRequest(new { message = "el token no corresponde a su usuario" }); if (validacion1 == false) return BadRequest(new { message = "el token no corresponde a su usuario" });
@@ -97,9 +103,10 @@ public class NotificacionesController: ControllerBase {
} }
[HttpPost("api/notificarInquilino")] [HttpPost("api/notificarInquilino")]
public IActionResult NotificarInq([FromHeader(Name ="Auth")]string Auth, [FromBody] AvisoInquilinoDto data) { public IActionResult NotificarInq([FromHeader(Name = "Auth")] string Auth, [FromBody] AvisoInquilinoDto data)
{
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized(); if (String.IsNullOrWhiteSpace(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();
if (data.Mensaje == "") return BadRequest(new { message = "El campo Mensaje esta vacio" }); if (data.Mensaje == "") return BadRequest(new { message = "El campo Mensaje esta vacio" });
@@ -123,14 +130,15 @@ public class NotificacionesController: ControllerBase {
} }
[HttpPost("api/notificar/ConsultaCompra")] [HttpPost("api/notificar/ConsultaCompra")]
public IActionResult EnviarConsultaCompra([FromHeader(Name ="Auth")]string Auth, AltaNotificacionDto dto) { public IActionResult EnviarConsultaCompra([FromHeader(Name = "Auth")] string Auth, AltaNotificacionDto dto)
{
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized(); if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized();
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario"); var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 16);
if (validacion1 == false){ if (validacion1 == false)
validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino"); {
if (validacion1 == false) {
return Unauthorized(); return Unauthorized();
}
} }
if (dto.Accion == "") return BadRequest(new { message = "El campo Accion esta vacio" }); if (dto.Accion == "") return BadRequest(new { message = "El campo Accion esta vacio" });