Falta hacer la notificacion nueva
This commit is contained in:
@@ -27,4 +27,8 @@ public class NotificacionDtoBuilder: Builder<NotificacionDto> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public NotificacionDtoBuilder SetReceptor(string receptor) {
|
||||
data.Receptor = receptor;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -44,9 +44,10 @@ public class ContratoController: ControllerBase {
|
||||
.SetIndiceActializacionInicial()
|
||||
.SetMesesHastaAumento(dto.MesesHastaAumento)
|
||||
.SetPropiedad(p.Id)
|
||||
.SetFecha(dto.fechaprimernotificacion)
|
||||
.SetFecha(DateTime.Parse(dto.fechaprimernotificacion))
|
||||
.Build();
|
||||
|
||||
|
||||
var notificacion = new NotificacioneBuilder()
|
||||
.SetAccion("Carge Garantes")
|
||||
.SetDniremitente(propi.Dni)
|
||||
@@ -58,7 +59,9 @@ public class ContratoController: ControllerBase {
|
||||
.Build();
|
||||
|
||||
var ret = RepositorioContratos.Singleton.CargaPrecontrato(precontrato, notificacion);
|
||||
|
||||
if (ret) {
|
||||
ret = RepositorioNotificaciones.Singleton.MarcarComoLeido(cli.Dni, DateTime.Parse(dto.fechaprimernotificacion));
|
||||
}
|
||||
return (ret)?
|
||||
Ok(new {message = "Se Cargo el precontrato y envio una notificacion al inquilino"}):
|
||||
BadRequest(new {message = "No se pudo cargar el precontrato"});
|
||||
@@ -73,9 +76,16 @@ public class ContratoController: ControllerBase {
|
||||
var validacion2 = ValidarDtoAltaGarantes(dto);
|
||||
if (validacion2 != "") return BadRequest(new {message = validacion2});
|
||||
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return BadRequest(new {message = "Tu token no corresponde a ningun cliente (volvete a logear)"});
|
||||
if (cli.Email != dto.EmailInquilino) return BadRequest(new {message = "No Corresponde el email de inquilino con el del token"});
|
||||
|
||||
var validacion4 = RepositorioContratos.Singleton.CantidadGarantesEncontrato(dto.EmailInquilino, dto.Idpropiedad);
|
||||
if (validacion4 <= 0 || dto.garantes.Count()!=validacion4) return BadRequest(new{message="Cantidad de garantes incorrecta"});
|
||||
|
||||
Cliente? propi = RepositorioPropietario.Singleton.ObtenerPropietarioPorIdPropiedad(dto.Idpropiedad);
|
||||
if(propi == null) return BadRequest(new{message = "No se encuentra el propietario de la propiedad"});
|
||||
|
||||
foreach (var i in dto.garantes) {
|
||||
string validacion3 = ValidarDtoGarante(i);
|
||||
if (validacion3 != "") return BadRequest( new { message = validacion3 });
|
||||
@@ -96,6 +106,22 @@ public class ContratoController: ControllerBase {
|
||||
}
|
||||
|
||||
var ret = RepositorioContratos.Singleton.CargaGarantes(gar, dto.EmailInquilino, dto.Idpropiedad);
|
||||
if (ret) {
|
||||
Console.WriteLine(dto.fecha);
|
||||
ret = RepositorioNotificaciones.Singleton.MarcarComoLeido(cli.Dni, dto.fecha);
|
||||
|
||||
var noti = new NotificacioneBuilder()
|
||||
.SetIdpropiedad(dto.Idpropiedad)
|
||||
.SetAccion("Comprobar Garantes")
|
||||
.SetMensaje($"")
|
||||
.SetLeido(false)
|
||||
.SetDniremitente(cli.Dni)
|
||||
.SetDnicliente()
|
||||
.SetFecha(DateTime.Now)
|
||||
|
||||
.Build()
|
||||
}
|
||||
|
||||
|
||||
return ret ?
|
||||
Ok(new {message = "Se Añadieron los Garantes"}):BadRequest(new { message = "Fallo la carga"});
|
||||
|
||||
@@ -26,6 +26,7 @@ public class NotificacionesController: ControllerBase {
|
||||
.SetMensaje(i.Mensaje)
|
||||
.SetFecha(i.Fecha)
|
||||
.SetPropiedad(i.IdpropiedadNavigation.Id.ToString())
|
||||
.SetReceptor(i.DniclienteNavigation.Email)
|
||||
.Build();
|
||||
|
||||
noti.Add(dto);
|
||||
|
||||
Reference in New Issue
Block a user