funcionalidad terminada
This commit is contained in:
@@ -121,4 +121,38 @@ public class NotificacionesController: ControllerBase {
|
||||
return ret?
|
||||
Ok(new { message = "se envio el aviso" }):BadRequest(new { message = "Fallo al intentar enviar el aviso" });
|
||||
}
|
||||
|
||||
[HttpPost("api/notificar/ConsultaCompra")]
|
||||
public IActionResult EnviarConsultaCompra([FromHeader(Name ="Auth")]string Auth, AltaNotificacionDto dto) {
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
if (validacion1 == false){
|
||||
validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||
if (validacion1 == false) {
|
||||
return Unauthorized();
|
||||
}
|
||||
}
|
||||
|
||||
if (dto.Accion == "") return BadRequest(new{message = "El campo Accion esta vacio"});
|
||||
if (dto.Mensaje == "") return BadRequest(new {message = "El campo Mensaje esta vacio"});
|
||||
|
||||
Cliente?cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
|
||||
Propiedade? prop = RepositorioPropiedades.Singleton.ObtenerPropiedadPorId(dto.Propiedad);
|
||||
if (prop == null) return BadRequest(new { message = "No hay una propiedad con id 0 o menor"});
|
||||
|
||||
var n = new NotificacioneBuilder()
|
||||
.SetAccion("Consulta Compra")
|
||||
.SetMensaje(dto.Mensaje)
|
||||
.SetLeido(false)
|
||||
.SetDnicliente(prop.Dnipropietario??0)
|
||||
.SetDniremitente(cli.Dni)
|
||||
.SetIdpropiedad(prop.Id)
|
||||
.SetFecha(DateTime.Now)
|
||||
.Build();
|
||||
var ret2= RepositorioNotificaciones.Singleton.AltaNotificacion(n, cli.Dni);
|
||||
return ret2?
|
||||
Ok(new { message = "se envio el aviso" }):BadRequest(new { message = "Fallo al intentar enviar el aviso" });
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user