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";
|
||||
|
||||
8
Entidades/Dto/CancelarPrecontratoDto.cs
Normal file
8
Entidades/Dto/CancelarPrecontratoDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Entidades.Dto;
|
||||
public class CancelarPrecontratoDto {
|
||||
public string EmailPropietario { get; set; } ="";
|
||||
public string EmailInquilino { get; set; } ="";
|
||||
public DateTime fecha { get; set; }
|
||||
|
||||
public int idpropiedad { get; set; } = 0;
|
||||
}
|
||||
21
Front/src/Componentes/ModalCheckYContrato.svelte
Normal file
21
Front/src/Componentes/ModalCheckYContrato.svelte
Normal file
@@ -0,0 +1,21 @@
|
||||
<script lang="ts">
|
||||
import type { MensajeDto } from "../types";
|
||||
import { urlG } from "../stores/urlStore";
|
||||
|
||||
let {men, onCancel, onConfirm, putErrorModal}: {men: MensajeDto,
|
||||
onCancel:()=>void,
|
||||
onConfirm:()=>void,
|
||||
putErrorModal:(txt:string)=>void} = $props();
|
||||
|
||||
async function getGaranteData() {
|
||||
try {
|
||||
const responce = await fetch($urlG+"". {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(sessionStorage.getItem("token")),
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -182,8 +182,16 @@
|
||||
|
||||
if (responce.ok){
|
||||
let data = await responce.json();
|
||||
|
||||
modaldata = data.message;
|
||||
if (mostrarleidos) {
|
||||
Leidos();
|
||||
} else {
|
||||
SinLeer();
|
||||
}
|
||||
return;
|
||||
}
|
||||
let dataaa = await responce.json();
|
||||
modaldata = dataaa.message;
|
||||
} catch {
|
||||
modaldata = "no se pudo comunicar con el Servidor";
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
|
||||
Contrato? contr = con.Contratos.Include(x=>x.DniinquilinoNavigation).Include(x=>x.Idgarantes)
|
||||
.FirstOrDefault(x=>x.Idpropiedad == idpropiedad &&
|
||||
x.DniinquilinoNavigation.Email == emailInquilino &&
|
||||
x.Habilitado == 0);
|
||||
x.Habilitado == 0 &&
|
||||
x.Cancelado == 0);
|
||||
|
||||
if (contr == null) return false;
|
||||
int inicial = (con.Garantes.Any()? con.Garantes.Max(x=>x.Id): 0) + 1;
|
||||
@@ -54,8 +55,21 @@ public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
|
||||
Contrato? contr = con.Contratos.Include(x=>x.DniinquilinoNavigation)
|
||||
.FirstOrDefault(x=>x.Idpropiedad == idpropiedad &&
|
||||
x.DniinquilinoNavigation.Email == emailInquilino &&
|
||||
x.Habilitado == 0);
|
||||
x.Habilitado == 0 &&
|
||||
x.Cancelado == 0);
|
||||
if (contr == null) return 0;
|
||||
return contr.Cantgarantemin;
|
||||
}
|
||||
|
||||
public Contrato? ObtenerContrato(string emailInquilino, int idpropiedad) {
|
||||
var con = Context;
|
||||
Contrato? contr = con.Contratos.Include(x=>x.DniinquilinoNavigation)
|
||||
.FirstOrDefault(x=>x.Idpropiedad == idpropiedad &&
|
||||
x.DniinquilinoNavigation.Email == emailInquilino &&
|
||||
x.Habilitado == 0 &&
|
||||
x.Cancelado == 0);
|
||||
if (contr == null) return null;
|
||||
return contr;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,9 +162,7 @@ public class RepositorioPropiedades: RepositorioBase<RepositorioPropiedades> {
|
||||
|
||||
if (prop == null||prop.Dnipropietario == 0) return false;
|
||||
|
||||
if (prop.Idestado == 2) return false;
|
||||
//las alquiladas no se pueden dar de baja claramente
|
||||
prop.Idestado = prop.Idestado == 1 ? 3 : 1;
|
||||
prop.Idestado = prop.Idestado == 3 ? 1 : 3;
|
||||
|
||||
return Guardar(con);
|
||||
}
|
||||
|
||||
@@ -34,9 +34,10 @@ public class RepositorioPropietario: RepositorioBase<RepositorioPropietario> {
|
||||
|
||||
public Cliente? ObtenerPropietarioPorIdPropiedad(int idpropiedad) {
|
||||
var con = Context;
|
||||
Propiedade? pro = con.Propiedades.Include(x=>x.DnipropietarioNavigation).FirstOrDefault(x=>x.Id == idpropiedad)
|
||||
if (pro == null) return null;
|
||||
Propiedade? pro = con.Propiedades.Include(x=>x.DnipropietarioNavigation)
|
||||
.FirstOrDefault(x=>x.Id == idpropiedad);
|
||||
if (pro == null || pro.DnipropietarioNavigation == null) return null;
|
||||
|
||||
|
||||
return pro.DnipropietarioNavigation;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user