creo que estoy con esto
This commit is contained in:
4
.editorconfig
Normal file
4
.editorconfig
Normal file
@@ -0,0 +1,4 @@
|
||||
[*.cs]
|
||||
|
||||
# CS8602: Dereference of a possibly null reference.
|
||||
dotnet_diagnostic.CS8602.severity = suggestion
|
||||
@@ -95,4 +95,30 @@ public class NotificacionesController: ControllerBase {
|
||||
return ret?
|
||||
Ok(new {message = "Se envio la notificacion"}):BadRequest(new {message = "Fallo al intentar guardar la notificacion"});
|
||||
}
|
||||
|
||||
[HttpPost("api/notificarInquilino")]
|
||||
public IActionResult NotificarInq([FromHeader(Name ="Auth")]string Auth, [FromBody] AvisoInquilinoDto data) {
|
||||
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
if (validacion1 == false)return Unauthorized();
|
||||
|
||||
if (data.Mensaje == "") return BadRequest(new {message = "El campo Mensaje esta vacio"});
|
||||
if (data.Idpropiedad <= 0) return BadRequest(new {message = "La id de propiedad no puede ser 0 o menor"});
|
||||
|
||||
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(data.Idpropiedad);
|
||||
if (cont == null || cont.DniinquilinoNavigation == null || cont.DnipropietarioNavigation == null || cont.IdpropiedadNavigation == null) return BadRequest(new { message = "no hay un contrato por esa id"});
|
||||
|
||||
var n = new NotificacioneBuilder()
|
||||
.SetAccion("Notificacion Inquilino")
|
||||
.SetMensaje(data.Mensaje)
|
||||
.SetLeido(false)
|
||||
.SetDnicliente(cont.DniinquilinoNavigation.Dni)
|
||||
.SetDniremitente(cont.DnipropietarioNavigation.Dni)
|
||||
.SetIdpropiedad(cont.IdpropiedadNavigation.Id)
|
||||
.SetFecha(DateTime.Now)
|
||||
.Build();
|
||||
var ret = RepositorioNotificaciones.Singleton.AltaNotificacion(n);
|
||||
return ret?
|
||||
Ok(new { message = "se envio el aviso" }):BadRequest(new { message = "Fallo al intentar enviar el aviso" });
|
||||
}
|
||||
}
|
||||
5
Entidades/Dto/AvisoInquilinoDto.cs
Normal file
5
Entidades/Dto/AvisoInquilinoDto.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Entidades.Dto;
|
||||
public class AvisoInquilinoDto {
|
||||
public string Mensaje { get; set; } ="";
|
||||
public long Idpropiedad { get; set; }
|
||||
}
|
||||
56
Front/src/Componentes/ModalNotificacion.svelte
Normal file
56
Front/src/Componentes/ModalNotificacion.svelte
Normal file
@@ -0,0 +1,56 @@
|
||||
<script lang="ts">
|
||||
let {onCancel, onConfirm}: {onCancel:()=>void, onConfirm:(message:string)=>void} = $props();
|
||||
|
||||
let message:string = $state("");
|
||||
const maxLength = $state(100);
|
||||
|
||||
function handleConfirm(e:Event) {
|
||||
e.preventDefault();
|
||||
if (message.length <= maxLength) {
|
||||
onConfirm(message);
|
||||
onCancel();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="modal fade show d-block"
|
||||
tabindex="-1"
|
||||
style="background-color: rgba(0, 0, 0, 0.5);"
|
||||
>
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Confirmar acción</h5>
|
||||
<button type="button" class="btn-close" aria-label="Close" onclick={onCancel}></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form onsubmit={(e)=>handleConfirm(e)}>
|
||||
<div class="mb-3">
|
||||
<label for="message" class="form-label">Mensaje</label>
|
||||
<input
|
||||
type="text"
|
||||
id="message"
|
||||
class="form-control"
|
||||
bind:value={message}
|
||||
maxlength={maxLength}
|
||||
required
|
||||
/>
|
||||
<div class="form-text">
|
||||
Caracteres restantes: {maxLength - message.length}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer d-flex justify-content-between">
|
||||
<button type="button" class="btn btn-secondary" onclick={onCancel}>
|
||||
Cancelar
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary" onclick={(e)=>handleConfirm(e)}>
|
||||
Confirmar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -6,6 +6,7 @@
|
||||
import type { CanonDto, ContratoDto, ContratoPropiedadDto, GaranteDto2 } from "../types";
|
||||
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
||||
import ModalPedirDoc from "../Componentes/ModalPedirDoc.svelte";
|
||||
import ModalNotificacion from "../Componentes/ModalNotificacion.svelte";
|
||||
|
||||
|
||||
let token:string = sessionStorage.getItem("token")||"";
|
||||
@@ -13,6 +14,9 @@
|
||||
let interes:number = $state(0);
|
||||
let selMod:any =$state();
|
||||
let showmodal:boolean = $state(false);
|
||||
let shownotif:boolean = $state(false);
|
||||
|
||||
let max:number=$state(0);
|
||||
|
||||
let canons:CanonDto[] = $state([]);
|
||||
let garantes: GaranteDto2[] = $state([]);
|
||||
@@ -34,9 +38,10 @@
|
||||
let modaldata:string = $state("");
|
||||
let contratoid:string = $state("");
|
||||
|
||||
onMount(()=>{
|
||||
onMount(async ()=>{
|
||||
getparams();
|
||||
obtenerDatosACargar();
|
||||
await obtenerDatosACargar();
|
||||
max = canons.at(-1).mesNum||0;
|
||||
});
|
||||
|
||||
async function obtenerDatosACargar() {
|
||||
@@ -78,12 +83,14 @@
|
||||
contratoid = par.get("id")||"";
|
||||
}
|
||||
|
||||
async function submitnuevosCanones() {
|
||||
async function submitnuevosCanones(e: Event) {
|
||||
e.preventDefault();
|
||||
try {
|
||||
const ret = await fetch($urlG+"/api/contratos/crearcanons",{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Auth" : String(token),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({idcontrato: contratoid, aumento: interes})
|
||||
});
|
||||
@@ -169,7 +176,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function generarTiket(mod) {
|
||||
function generarTiket(mod:any) {
|
||||
selMod = mod;
|
||||
showmodal =true;
|
||||
}
|
||||
@@ -198,6 +205,34 @@
|
||||
modaldata = "Fallo al intentar hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
async function EscribirNotificacion(message:string) {
|
||||
if (message =="") {
|
||||
modaldata = "no se puede enviar un mensaje vacio";
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const r = await fetch($urlG+"/api/notificarInquilino", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
mensaje: message,
|
||||
idpropiedad: prop.id
|
||||
})
|
||||
});
|
||||
let data = await r.json();
|
||||
modaldata = data.message;
|
||||
} catch {
|
||||
modaldata ="No se pudo enviar el mensaje";
|
||||
}
|
||||
}
|
||||
|
||||
function abrirModalNotif() {
|
||||
shownotif = true;
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
@@ -210,6 +245,10 @@
|
||||
<ModalPedirDoc onClose={()=>showmodal=false} onSubmit={pedirdocumento} />
|
||||
{/if}
|
||||
|
||||
{#if shownotif}
|
||||
<ModalNotificacion onCancel={()=>shownotif = false} onConfirm={EscribirNotificacion}/>
|
||||
{/if}
|
||||
|
||||
<div class="container-fluid mt-4 d-flex">
|
||||
<div class="col-md-4 me-4">
|
||||
<div class="card">
|
||||
@@ -224,9 +263,14 @@
|
||||
<p><b>Letra:</b> {prop.letra}</p>
|
||||
<p><b>Fecha Inicio:</b> {String(prop.fechainicio).split("T")[0]}</p>
|
||||
<p><b>Estado:</b> {prop.estado}</p>
|
||||
<div class="d-flex justify-content-between">
|
||||
<button class="btn btn-secondary" onclick={verContrato}>
|
||||
Ver Contrato
|
||||
</button>
|
||||
<button class="btn btn-warning" onclick={abrirModalNotif}>
|
||||
Enviar Notificacion
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer text-center">
|
||||
IdContrato: {prop.id}
|
||||
@@ -327,6 +371,8 @@
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
{#if max < prop.mesesDuracion}
|
||||
{$inspect(max)}
|
||||
<div class="card">
|
||||
<div class="card-header text-center">
|
||||
Definir el interés para los siguientes Canones
|
||||
@@ -347,13 +393,14 @@
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
type="submit"
|
||||
onclick={() => submitnuevosCanones()}
|
||||
onclick={(e) => submitnuevosCanones(e)}
|
||||
>
|
||||
Enviar
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -130,6 +130,11 @@
|
||||
Selmens = {...mensaje};
|
||||
return;
|
||||
}
|
||||
|
||||
if (mensaje.accion === "Notificacion Inquilino") {
|
||||
Selmens = {...mensaje};
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async function obtenerListaGarantes(idcontrato: number) {
|
||||
@@ -422,6 +427,8 @@
|
||||
<ModalCheckYContrato {garantes} men={Selmens} onCancel={handleCancelPrecontrato} onClose={() => (Selmens.accion = "")} onConfirm={handleEnviarmensaje4}/>
|
||||
{:else if Selmens.accion == "Aceptar Contrato"}
|
||||
<ModalVeryAceptarContrato onClose={() => (Selmens.accion = "")} onConfirm={handleAceptarContrato} onCancel={handlerechazarcontrato} getContrato={ObtenerContrato} men={Selmens}/>
|
||||
{:else if Selmens.accion == "Notificacion Inquilino"}
|
||||
<ModalEstatico payload={Selmens.mensaje} close={()=> !!(Selmens.accion = "") }/>
|
||||
{/if}
|
||||
|
||||
<div class="container">
|
||||
@@ -483,9 +490,10 @@
|
||||
</button>
|
||||
{/if}
|
||||
{#if (men.accion === "ContratoCancelado" || men.accion === "Rechazo Contrato" ||
|
||||
men.accion === "Aceptado Contrato") && mostrarleidos == false}
|
||||
men.accion === "Aceptado Contrato" || men.accion === "Notificacion Inquilino"
|
||||
) && mostrarleidos == false}
|
||||
<button
|
||||
class="btn btn-outline-danger"
|
||||
class="btn btn-outline-danger btn-sm"
|
||||
onclick={() => marcarleido(men.fecha, localStorage.getItem("email")|| "", men)}>
|
||||
Marcar Leido
|
||||
</button>
|
||||
|
||||
@@ -40,9 +40,10 @@ public class RepositorioCanons: RepositorioBase<RepositorioCanons> {
|
||||
return Guardar(con);
|
||||
}
|
||||
|
||||
public bool CrearCanons(decimal aumento, long idcontrato) { //WIP
|
||||
public bool CrearCanons(decimal aumento, long idcontrato) {
|
||||
var con = Context;
|
||||
|
||||
aumento/=100;
|
||||
aumento+=1;
|
||||
|
||||
var cont = con.Contratos.Include(x=>x.Idcanons).FirstOrDefault(x=>x.Id == idcontrato);
|
||||
@@ -52,7 +53,7 @@ public class RepositorioCanons: RepositorioBase<RepositorioCanons> {
|
||||
Canon? d = cont.Idcanons.OrderByDescending(x=>x.Fecha).FirstOrDefault();
|
||||
if (d == null) return false;
|
||||
|
||||
|
||||
if (exist == cont.MesesDurationContrato) return false;
|
||||
if (exist+cont.MesesHastaAumento >= cont.MesesDurationContrato){
|
||||
exist = cont.MesesDurationContrato-exist;
|
||||
} else{
|
||||
|
||||
Reference in New Issue
Block a user