algun avance tengo
This commit is contained in:
@@ -105,30 +105,55 @@ public class ContratoController: ControllerBase {
|
||||
gar.Add(g);
|
||||
}
|
||||
|
||||
var contr = RepositorioContratos.Singleton.ObtenerContrato(dto.EmailInquilino, dto.Idpropiedad);
|
||||
if (contr == null) return BadRequest(new { message = "No existe el contrato o ya fue activado"});
|
||||
|
||||
var ret = RepositorioContratos.Singleton.CargaGarantes(gar, dto.EmailInquilino, dto.Idpropiedad);
|
||||
if (ret) {
|
||||
Console.WriteLine(dto.fecha);
|
||||
ret = RepositorioNotificaciones.Singleton.MarcarComoLeido(cli.Dni, dto.fecha);
|
||||
|
||||
RepositorioNotificaciones.Singleton.MarcarComoLeido(cli.Dni, dto.fecha);
|
||||
|
||||
var noti = new NotificacioneBuilder()
|
||||
.SetIdpropiedad(dto.Idpropiedad)
|
||||
.SetAccion("Comprobar Garantes")
|
||||
.SetMensaje($"")
|
||||
.SetAccion("Check y Contrato")
|
||||
.SetMensaje($"El inquilino cargó los datos de garantes comprobá y carga el contrato: {contr.Id}")
|
||||
.SetLeido(false)
|
||||
.SetDniremitente(cli.Dni)
|
||||
.SetDnicliente()
|
||||
.SetDnicliente(propi.Dni)
|
||||
.SetFecha(DateTime.Now)
|
||||
|
||||
.Build()
|
||||
.Build();
|
||||
ret = RepositorioNotificaciones.Singleton.AltaNotificacion(noti);
|
||||
}
|
||||
|
||||
|
||||
return ret ?
|
||||
Ok(new {message = "Se Añadieron los Garantes"}):BadRequest(new { message = "Fallo la carga"});
|
||||
}
|
||||
|
||||
[HttpPut("api/contratos/cancelar")]
|
||||
public IActionResult CancelarPrecontrato([FromHeader(Name = "Auth")]string Auth, CancelarPrecontratoDto dto) {
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
private string ValidarDtoGarante(GaranteDto g){
|
||||
var validacion2 = ValidarCancelarDto(dto);
|
||||
if (validacion2 != "") return BadRequest(new {message = validacion2});
|
||||
|
||||
Cliente? pro = RepositorioPropietario.Singleton.ObtenerPropietarioPorEmail(dto.EmailPropietario);
|
||||
if (pro == null) return BadRequest(new {message = "No Existe Usuario con ese email"});
|
||||
if (pro.Token != Auth) return BadRequest(new {message = "El token de auth no corresponde al token el usuario propietario"});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private string ValidarCancelarDto(CancelarPrecontratoDto dto) {
|
||||
if (dto == null) return "dto nulo";
|
||||
string ret = "";
|
||||
|
||||
if (dto.EmailInquilino =="") ret += "No puede tener un EmailInquilino Vacio\n";
|
||||
if (dto.EmailPropietario =="") ret += "No puede tener un EmailPropietario Vacio\n";
|
||||
if (dto.idpropiedad <= 0 ) ret += "No puede tener id propiedad igual o menor a 0\n";
|
||||
if (dto.fecha == DateTime.MinValue) ret += "Falta fecha\n";
|
||||
}
|
||||
private string ValidarDtoGarante(GaranteDto g) {
|
||||
string ret = "";
|
||||
if (g == null) return "dto nulo";
|
||||
|
||||
@@ -156,6 +181,7 @@ public class ContratoController: ControllerBase {
|
||||
if (dto == null) return "dto nulo";
|
||||
|
||||
if (dto.CantidadGarantes<0) ret += "la cantidad de garantes necesarios no pueden ser menor a 0\n";
|
||||
if (dto.CantidadGarantes>10) ret += "Hay un maximo de 10 garantes\n";
|
||||
if (dto.EmailInquilino == "") ret += "el email del inquilino no puede ser nulo\n";
|
||||
if (dto.EmailPropietario == "") ret += "el email del propietario no puede estar vacio\n";
|
||||
if (dto.IdPropiedad <= 0) ret += "la id de propiedad no puede ser igual o menor a 0\n";
|
||||
|
||||
Reference in New Issue
Block a user