Falta hacer la notificacion nueva
This commit is contained in:
@@ -27,4 +27,8 @@ public class NotificacionDtoBuilder: Builder<NotificacionDto> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NotificacionDtoBuilder SetReceptor(string receptor) {
|
||||||
|
data.Receptor = receptor;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -44,9 +44,10 @@ public class ContratoController: ControllerBase {
|
|||||||
.SetIndiceActializacionInicial()
|
.SetIndiceActializacionInicial()
|
||||||
.SetMesesHastaAumento(dto.MesesHastaAumento)
|
.SetMesesHastaAumento(dto.MesesHastaAumento)
|
||||||
.SetPropiedad(p.Id)
|
.SetPropiedad(p.Id)
|
||||||
.SetFecha(dto.fechaprimernotificacion)
|
.SetFecha(DateTime.Parse(dto.fechaprimernotificacion))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|
||||||
var notificacion = new NotificacioneBuilder()
|
var notificacion = new NotificacioneBuilder()
|
||||||
.SetAccion("Carge Garantes")
|
.SetAccion("Carge Garantes")
|
||||||
.SetDniremitente(propi.Dni)
|
.SetDniremitente(propi.Dni)
|
||||||
@@ -58,7 +59,9 @@ public class ContratoController: ControllerBase {
|
|||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var ret = RepositorioContratos.Singleton.CargaPrecontrato(precontrato, notificacion);
|
var ret = RepositorioContratos.Singleton.CargaPrecontrato(precontrato, notificacion);
|
||||||
|
if (ret) {
|
||||||
|
ret = RepositorioNotificaciones.Singleton.MarcarComoLeido(cli.Dni, DateTime.Parse(dto.fechaprimernotificacion));
|
||||||
|
}
|
||||||
return (ret)?
|
return (ret)?
|
||||||
Ok(new {message = "Se Cargo el precontrato y envio una notificacion al inquilino"}):
|
Ok(new {message = "Se Cargo el precontrato y envio una notificacion al inquilino"}):
|
||||||
BadRequest(new {message = "No se pudo cargar el precontrato"});
|
BadRequest(new {message = "No se pudo cargar el precontrato"});
|
||||||
@@ -73,9 +76,16 @@ public class ContratoController: ControllerBase {
|
|||||||
var validacion2 = ValidarDtoAltaGarantes(dto);
|
var validacion2 = ValidarDtoAltaGarantes(dto);
|
||||||
if (validacion2 != "") return BadRequest(new {message = validacion2});
|
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);
|
var validacion4 = RepositorioContratos.Singleton.CantidadGarantesEncontrato(dto.EmailInquilino, dto.Idpropiedad);
|
||||||
if (validacion4 <= 0 || dto.garantes.Count()!=validacion4) return BadRequest(new{message="Cantidad de garantes incorrecta"});
|
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) {
|
foreach (var i in dto.garantes) {
|
||||||
string validacion3 = ValidarDtoGarante(i);
|
string validacion3 = ValidarDtoGarante(i);
|
||||||
if (validacion3 != "") return BadRequest( new { message = validacion3 });
|
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);
|
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 ?
|
return ret ?
|
||||||
Ok(new {message = "Se Añadieron los Garantes"}):BadRequest(new { message = "Fallo la carga"});
|
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)
|
.SetMensaje(i.Mensaje)
|
||||||
.SetFecha(i.Fecha)
|
.SetFecha(i.Fecha)
|
||||||
.SetPropiedad(i.IdpropiedadNavigation.Id.ToString())
|
.SetPropiedad(i.IdpropiedadNavigation.Id.ToString())
|
||||||
|
.SetReceptor(i.DniclienteNavigation.Email)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
noti.Add(dto);
|
noti.Add(dto);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ namespace Entidades.Dto;
|
|||||||
public class NotificacionDto {
|
public class NotificacionDto {
|
||||||
public string Remitente { get; set; } ="";
|
public string Remitente { get; set; } ="";
|
||||||
public string Accion { get; set; } ="";
|
public string Accion { get; set; } ="";
|
||||||
|
public string Receptor { get; set; } ="";
|
||||||
public string Mensaje { get; set; } ="";
|
public string Mensaje { get; set; } ="";
|
||||||
public DateTime? Fecha{get; set;} =null;
|
public DateTime? Fecha{get; set;} =null;
|
||||||
public string Propiedad { get; set;} ="";
|
public string Propiedad { get; set;} ="";
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ public class PrecontratoDto {
|
|||||||
public int CantidadGarantes { get; set; }
|
public int CantidadGarantes { get; set; }
|
||||||
public int MesesHastaAumento { get; set; }
|
public int MesesHastaAumento { get; set; }
|
||||||
public bool TieneOpcionVenta { get; set; }
|
public bool TieneOpcionVenta { get; set; }
|
||||||
public DateTime fechaprimernotificacion { get; set; }
|
public string fechaprimernotificacion { get; set; }
|
||||||
}
|
}
|
||||||
165
Front/src/Componentes/ModalAddGarantes.svelte
Normal file
165
Front/src/Componentes/ModalAddGarantes.svelte
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { GaranteDto } from "../types";
|
||||||
|
|
||||||
|
let { onClose, onSubmit, maxGarantes }: {
|
||||||
|
onClose: () => void,
|
||||||
|
onSubmit: (garantes: GaranteDto[]) => void,
|
||||||
|
maxGarantes: number
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
let cantGarantes: number = $state(0);
|
||||||
|
let garantes: GaranteDto[] = $state([]);
|
||||||
|
let showAddForm: boolean = $state(false);
|
||||||
|
|
||||||
|
// Nuevo garante temporal para el formulario.
|
||||||
|
let newGarante: GaranteDto = $state({
|
||||||
|
Dni: 0,
|
||||||
|
Nombre: "",
|
||||||
|
Apellido: "",
|
||||||
|
Domicilio: "",
|
||||||
|
Celular: "",
|
||||||
|
Domiciliolaboral: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleSubmit(e: Event) {
|
||||||
|
e.preventDefault();
|
||||||
|
onSubmit(garantes);
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
function addGarante() {
|
||||||
|
if (cantGarantes < maxGarantes) {
|
||||||
|
garantes = [...garantes, { ...newGarante }];
|
||||||
|
cantGarantes = garantes.length;
|
||||||
|
resetNewGarante();
|
||||||
|
showAddForm = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetNewGarante() {
|
||||||
|
newGarante = {
|
||||||
|
Dni: 0,
|
||||||
|
Nombre: "",
|
||||||
|
Apellido: "",
|
||||||
|
Domicilio: "",
|
||||||
|
Celular: "",
|
||||||
|
Domiciliolaboral: ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="modal fade show" tabindex="-1" role="dialog" style="display: block; background-color: rgba(0, 0, 0, 0.5);">
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Nuevo Alquiler - Garantes</h5>
|
||||||
|
<button class="btn-close" onclick={onClose} aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form onsubmit={handleSubmit}>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="mb-3">
|
||||||
|
<p>Garantes añadidos: {cantGarantes}/{maxGarantes}</p>
|
||||||
|
<button
|
||||||
|
class="btn btn-success"
|
||||||
|
type="button"
|
||||||
|
onclick={() => (showAddForm = true)}
|
||||||
|
disabled={cantGarantes >= maxGarantes}
|
||||||
|
>
|
||||||
|
Añadir Garante
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Formulario para añadir un garante -->
|
||||||
|
{#if showAddForm}
|
||||||
|
<div class="form-group mt-3">
|
||||||
|
<h6>Añadir Garante</h6>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label>DNI</label>
|
||||||
|
<input type="number" class="form-control" bind:value={newGarante.Dni} required />
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label>Nombre</label>
|
||||||
|
<input type="text" class="form-control" bind:value={newGarante.Nombre} required />
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label>Apellido</label>
|
||||||
|
<input type="text" class="form-control" bind:value={newGarante.Apellido} required />
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label>Domicilio</label>
|
||||||
|
<input type="text" class="form-control" bind:value={newGarante.Domicilio} required />
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label>Celular</label>
|
||||||
|
<input type="text" class="form-control" bind:value={newGarante.Celular} required />
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label>Domicilio Laboral</label>
|
||||||
|
<input type="text" class="form-control" bind:value={newGarante.Domiciliolaboral} required />
|
||||||
|
</div>
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<button
|
||||||
|
class="btn btn-secondary"
|
||||||
|
type="button"
|
||||||
|
onclick={() => (showAddForm = false)}
|
||||||
|
>
|
||||||
|
Cancelar
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-primary" type="button" onclick={addGarante}>
|
||||||
|
Confirmar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!-- Tabla de garantes -->
|
||||||
|
{#if cantGarantes > 0}
|
||||||
|
<div class="form-group mt-3">
|
||||||
|
<label>Lista de Garantes</label>
|
||||||
|
<table class="table table-striped table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>DNI</th>
|
||||||
|
<th>Nombre</th>
|
||||||
|
<th>Apellido</th>
|
||||||
|
<th>Domicilio</th>
|
||||||
|
<th>Celular</th>
|
||||||
|
<th>Domicilio Laboral</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{#each garantes as garante, index}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="number" class="form-control" bind:value={garantes[index].Dni} required />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" class="form-control" bind:value={garantes[index].Nombre} required />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" class="form-control" bind:value={garantes[index].Apellido} required />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" class="form-control" bind:value={garantes[index].Domicilio} required />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" class="form-control" bind:value={garantes[index].Celular} required />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" class="form-control" bind:value={garantes[index].Domiciliolaboral} required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer d-flex justify-content-between">
|
||||||
|
<button type="button" class="btn btn-secondary" onclick={onClose}>Cancelar</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Confirmar</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
50
Front/src/Componentes/ModalPrecontrato.svelte
Normal file
50
Front/src/Componentes/ModalPrecontrato.svelte
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
let { onClose, onSubmit } : {
|
||||||
|
onClose: () => void,
|
||||||
|
onSubmit: (data: { opcionVenta: boolean; cantGarantes: number; mesesHastaAumento: number }) => void
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
let opcionVenta: boolean = $state(false);
|
||||||
|
let cantGarantes: number = $state(0);
|
||||||
|
let mesesHastaAumento: number = $state(0);
|
||||||
|
|
||||||
|
function handleSubmit(e:Event) {
|
||||||
|
e.preventDefault();
|
||||||
|
onSubmit({ opcionVenta, cantGarantes, mesesHastaAumento });
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="modal fade show" tabindex="-1" role="dialog" style="display: block; background-color: rgba(0, 0, 0, 0.5);">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Nuevo Alquiler</h5>
|
||||||
|
<button class="btn-close" onclick={onClose} aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form onsubmit={handleSubmit}>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group">
|
||||||
|
|
||||||
|
<div class="form-check">
|
||||||
|
<input type="checkbox" class="form-check-input" bind:checked={opcionVenta} id="opcionVenta" />
|
||||||
|
<label class="form-check-label" for="opcionVenta">Seleccionar Opcion de Venta</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="cantGarantes">Cantidad de Garantes</label>
|
||||||
|
<input type="number" class="form-control" id="cantGarantes" bind:value={cantGarantes} min="0" required />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="mesesHastaAumento">Meses Hasta Aumento</label>
|
||||||
|
<input type="number" class="form-control" id="mesesHastaAumento" bind:value={mesesHastaAumento} min="0" required />
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer d-flex justify-content-between">
|
||||||
|
<button type="button" class="btn btn-secondary" onclick={onClose}>Cancelar</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Confirmar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,23 +1,25 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
import type { MensajeDto } from "../types";
|
import type { GaranteDto, MensajeDto } from "../types";
|
||||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
import { urlG } from "../stores/urlStore";
|
import { urlG } from "../stores/urlStore";
|
||||||
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
||||||
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
import { text } from "@sveltejs/kit";
|
import { text } from "@sveltejs/kit";
|
||||||
|
import ModalPrecontrato from "../Componentes/ModalPrecontrato.svelte";
|
||||||
|
import { get } from "svelte/store";
|
||||||
|
import ModalAddGarantes from "../Componentes/ModalAddGarantes.svelte";
|
||||||
|
|
||||||
const token = sessionStorage.getItem("token");
|
const token = sessionStorage.getItem("token");
|
||||||
let mensajes: MensajeDto[] = $state([]);
|
let mensajes: MensajeDto[] = $state([]);
|
||||||
let showspinner:boolean =$state(false);
|
let showspinner:boolean =$state(false);
|
||||||
let mostrarleidos: boolean = $state(false);
|
let mostrarleidos: boolean = $state(false);
|
||||||
let modaldata:string =$state("");
|
let modaldata:string =$state("");
|
||||||
let Selmens: MensajeDto;
|
let Selmens: MensajeDto = $state({accion: "",receptor:"", fecha: Date.UTC, mensaje:"", propiedad:0, remitente:""});
|
||||||
|
|
||||||
let show:boolean = $state(false);
|
let show:boolean = $state(false);
|
||||||
let title:string = $state("");
|
let setCantGarantes = $state(0);
|
||||||
let message:string = $state("");
|
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
SinLeer();
|
SinLeer();
|
||||||
@@ -70,12 +72,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setModalConfirm(men:MensajeDto){
|
|
||||||
Selmens = men;
|
|
||||||
message = "${}"
|
|
||||||
show = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
async function marcarleido( fecha: Date, email: string, men:MensajeDto ) {
|
async function marcarleido( fecha: Date, email: string, men:MensajeDto ) {
|
||||||
show = true;
|
show = true;
|
||||||
@@ -92,7 +89,12 @@
|
|||||||
if (responce.ok) {
|
if (responce.ok) {
|
||||||
let data = await responce.json();
|
let data = await responce.json();
|
||||||
modaldata = data.message;
|
modaldata = data.message;
|
||||||
mensajes = mensajes.filter(m => m !== men);
|
|
||||||
|
if (mostrarleidos) {
|
||||||
|
Leidos();
|
||||||
|
} else {
|
||||||
|
SinLeer();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let dataerror = await responce.json();
|
let dataerror = await responce.json();
|
||||||
@@ -102,12 +104,89 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function abrirModal(mensaje: MensajeDto) {
|
||||||
|
if (mensaje.accion === "Nuevo Alquiler") {
|
||||||
|
Selmens = { ...mensaje };
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
function abrirModal(mensaje: MensajeDto) {
|
if (mensaje.accion === "Carge Garantes") {
|
||||||
Selmens = mensaje;
|
Selmens = { ...mensaje };
|
||||||
title = "Confirmar proceso de alquiler";
|
setCantGarantes = Number(Selmens.mensaje.split(" ").reverse()[1]);
|
||||||
message ="Aceptar este proceso eliminará la propiedad del menú de búsqueda. Se informará al inquilino que debe pasar los datos de sus garantías. ¿Desea continuar?";
|
return;
|
||||||
show = true;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleEnviarmensaje2(data: {opcionVenta:boolean, cantGarantes:number, mesesHastaAumento:number}) {
|
||||||
|
if (data.opcionVenta == null || data.cantGarantes <=0 || data.mesesHastaAumento<=0) {
|
||||||
|
modaldata = "Estan mal cargados los datos del form";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
let fecha = Selmens.fecha.toString();
|
||||||
|
const datata = {
|
||||||
|
tieneopcionventa: data.opcionVenta,
|
||||||
|
mesesHastaAumento: data.mesesHastaAumento,
|
||||||
|
cantidadGarantes: data.cantGarantes,
|
||||||
|
idPropiedad: Selmens.propiedad,
|
||||||
|
fechaprimernotificacion: fecha,
|
||||||
|
emailInquilino: localStorage.getItem("email"),
|
||||||
|
emailPropietario: Selmens.receptor,
|
||||||
|
};
|
||||||
|
|
||||||
|
let responce = await fetch($urlG+"/api/contratos/precontrato", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify(datata),
|
||||||
|
});
|
||||||
|
if(responce.ok) {
|
||||||
|
let dataaa = await responce.json();
|
||||||
|
modaldata = dataaa.message;
|
||||||
|
if (mostrarleidos) {
|
||||||
|
Leidos();
|
||||||
|
} else {
|
||||||
|
SinLeer();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let dataaa = await responce.json();
|
||||||
|
modaldata = dataaa.message;
|
||||||
|
return;
|
||||||
|
} catch (e) {
|
||||||
|
modaldata = "fallo al intentar conectar con el servidor: "+e
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleEnviarmensaje3(garantes: GaranteDto[]) {
|
||||||
|
try {
|
||||||
|
let dat = {
|
||||||
|
emailInquilino: localStorage.getItem("email") || "",
|
||||||
|
idpropiedad: Selmens.propiedad,
|
||||||
|
fecha: Selmens.fecha,
|
||||||
|
garantes: garantes
|
||||||
|
}
|
||||||
|
|
||||||
|
let responce = await fetch($urlG+"/api/contratos/addGarantes", {
|
||||||
|
method : "PUT",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify(dat),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (responce.ok){
|
||||||
|
let data = await responce.json();
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
modaldata = "no se pudo comunicar con el Servidor";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -118,13 +197,20 @@
|
|||||||
<ModalEstatico payload={modaldata} close={()=>!!(modaldata = "")} />
|
<ModalEstatico payload={modaldata} close={()=>!!(modaldata = "")} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<ModalConfirm
|
<!--
|
||||||
|
<ModalConfirm
|
||||||
{show}
|
{show}
|
||||||
{title}
|
{title}
|
||||||
{message}
|
{message}
|
||||||
onCancel={() => (show = false)}
|
onCancel={() => (show = false)}
|
||||||
onConfirm={()=>1+1}
|
onConfirm={()=>1+1}
|
||||||
/>
|
/>
|
||||||
|
-->
|
||||||
|
{#if Selmens.accion == "Nuevo Alquiler" }
|
||||||
|
<ModalPrecontrato onClose={() => (Selmens.accion = "")} onSubmit={handleEnviarmensaje2} />
|
||||||
|
{:else if Selmens.accion == "Carge Garantes"}
|
||||||
|
<ModalAddGarantes maxGarantes={setCantGarantes} onClose={() => (Selmens.accion = "")} onSubmit={handleEnviarmensaje3}/>
|
||||||
|
{/if}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<br>
|
<br>
|
||||||
<BarraHorizontalConTexto text="Notificaciones"/>
|
<BarraHorizontalConTexto text="Notificaciones"/>
|
||||||
@@ -148,6 +234,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Remitente</th>
|
<th>Remitente</th>
|
||||||
<th>Accion</th>
|
<th>Accion</th>
|
||||||
|
<th>Receptor</th>
|
||||||
<th>Mensaje</th>
|
<th>Mensaje</th>
|
||||||
<th>Fecha</th>
|
<th>Fecha</th>
|
||||||
<th>Propiedad</th>
|
<th>Propiedad</th>
|
||||||
@@ -169,18 +256,29 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{men.remitente}</td>
|
<td>{men.remitente}</td>
|
||||||
<td>{men.accion}</td>
|
<td>{men.accion}</td>
|
||||||
|
<td>{men.receptor}</td>
|
||||||
<td>{men.mensaje}</td>
|
<td>{men.mensaje}</td>
|
||||||
<td>{men.fecha}</td>
|
<td>{men.fecha}</td>
|
||||||
<td>{men.propiedad}</td>
|
<td>{men.propiedad}</td>
|
||||||
|
|
||||||
{#if mostrarleidos == false}
|
{#if mostrarleidos == false}
|
||||||
<td>
|
<td>
|
||||||
<button
|
<div class="d-flex">
|
||||||
class="btn btn-outline-primary btn-sm"
|
|
||||||
onclick={() => abrirModal(men)}
|
<button
|
||||||
>
|
class="btn btn-outline-primary"
|
||||||
Expandir
|
onclick={() => abrirModal(men)}
|
||||||
</button>
|
>
|
||||||
|
Expandir
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="btn btn-outline-danger"
|
||||||
|
onclick={() => marcarleido(men.fecha, localStorage.getItem("email")|| "", men)}
|
||||||
|
>
|
||||||
|
Marcar Leido
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
{/if}
|
{/if}
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
12
Front/src/types.d.ts
vendored
12
Front/src/types.d.ts
vendored
@@ -58,8 +58,18 @@ export type Propiedad = {
|
|||||||
export type MensajeDto = {
|
export type MensajeDto = {
|
||||||
remitente: string,
|
remitente: string,
|
||||||
accion: string,
|
accion: string,
|
||||||
|
receptor: string,
|
||||||
mensaje: string,
|
mensaje: string,
|
||||||
fecha: Date,
|
fecha: Date,
|
||||||
propiedad: string,
|
propiedad: string,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type GaranteDto = {
|
||||||
|
Dni: number;
|
||||||
|
Nombre: string;
|
||||||
|
Apellido: string;
|
||||||
|
Domicilio: string;
|
||||||
|
Celular: string;
|
||||||
|
Domiciliolaboral: string;
|
||||||
|
};
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
|
|||||||
if (prop == null) return false;
|
if (prop == null) return false;
|
||||||
prop.Idestado = 2;
|
prop.Idestado = 2;
|
||||||
|
|
||||||
c.Id = con.Contratos.Max(x=>x.Id)+1;
|
c.Id = (con.Contratos.Any() ? con.Contratos.Max(x => x.Id) : 0) + 1;
|
||||||
c.Monto = prop.Monto;
|
c.Monto = prop.Monto;
|
||||||
|
|
||||||
con.Contratos.Add(c);
|
con.Contratos.Add(c);
|
||||||
@@ -32,14 +32,17 @@ public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
|
|||||||
}
|
}
|
||||||
public bool CargaGarantes(List<Garante> gar, string emailInquilino, int idpropiedad) {
|
public bool CargaGarantes(List<Garante> gar, string emailInquilino, int idpropiedad) {
|
||||||
var con = Context;
|
var con = Context;
|
||||||
Contrato? contr = con.Contratos.Include(x=>x.DniinquilinoNavigation)
|
Contrato? contr = con.Contratos.Include(x=>x.DniinquilinoNavigation).Include(x=>x.Idgarantes)
|
||||||
.FirstOrDefault(x=>x.Idpropiedad == idpropiedad &&
|
.FirstOrDefault(x=>x.Idpropiedad == idpropiedad &&
|
||||||
x.DniinquilinoNavigation.Email == emailInquilino &&
|
x.DniinquilinoNavigation.Email == emailInquilino &&
|
||||||
x.Habilitado == 0);
|
x.Habilitado == 0);
|
||||||
|
|
||||||
if (contr == null) return false;
|
if (contr == null) return false;
|
||||||
|
int inicial = (con.Garantes.Any()? con.Garantes.Max(x=>x.Id): 0) + 1;
|
||||||
foreach (var i in gar) {
|
foreach (var i in gar) {
|
||||||
i.Id = con.Garantes.Max(x=>x.Id)+1;
|
i.Id = inicial;
|
||||||
|
inicial++;
|
||||||
|
con.Garantes.Add(i);
|
||||||
contr.Idgarantes.Add(i);
|
contr.Idgarantes.Add(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,4 +31,12 @@ public class RepositorioPropietario: RepositorioBase<RepositorioPropietario> {
|
|||||||
if (grupo == null) return null;
|
if (grupo == null) return null;
|
||||||
return cli;
|
return cli;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user