creo que estoy con esto
This commit is contained in:
@@ -95,4 +95,30 @@ public class NotificacionesController: ControllerBase {
|
||||
return ret?
|
||||
Ok(new {message = "Se envio la notificacion"}):BadRequest(new {message = "Fallo al intentar guardar la notificacion"});
|
||||
}
|
||||
|
||||
[HttpPost("api/notificarInquilino")]
|
||||
public IActionResult NotificarInq([FromHeader(Name ="Auth")]string Auth, [FromBody] AvisoInquilinoDto data) {
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
if (validacion1 == false)return Unauthorized();
|
||||
|
||||
if (data.Mensaje == "") return BadRequest(new {message = "El campo Mensaje esta vacio"});
|
||||
if (data.Idpropiedad <= 0) return BadRequest(new {message = "La id de propiedad no puede ser 0 o menor"});
|
||||
|
||||
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(data.Idpropiedad);
|
||||
if (cont == null || cont.DniinquilinoNavigation == null || cont.DnipropietarioNavigation == null || cont.IdpropiedadNavigation == null) return BadRequest(new { message = "no hay un contrato por esa id"});
|
||||
|
||||
var n = new NotificacioneBuilder()
|
||||
.SetAccion("Notificacion Inquilino")
|
||||
.SetMensaje(data.Mensaje)
|
||||
.SetLeido(false)
|
||||
.SetDnicliente(cont.DniinquilinoNavigation.Dni)
|
||||
.SetDniremitente(cont.DnipropietarioNavigation.Dni)
|
||||
.SetIdpropiedad(cont.IdpropiedadNavigation.Id)
|
||||
.SetFecha(DateTime.Now)
|
||||
.Build();
|
||||
var ret = RepositorioNotificaciones.Singleton.AltaNotificacion(n);
|
||||
return ret?
|
||||
Ok(new { message = "se envio el aviso" }):BadRequest(new { message = "Fallo al intentar enviar el aviso" });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user