termine lo que corresponde a logear los contratos
This commit is contained in:
@@ -34,6 +34,16 @@ public class NotificacionesController: ControllerBase {
|
|||||||
return Ok(noti);
|
return Ok(noti);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/notificaciones/haySinLeer")]
|
||||||
|
public IActionResult GetHayNotis([FromHeader(Name ="Auth")]string Auth) {
|
||||||
|
if (String.IsNullOrWhiteSpace(Auth)) return Unauthorized();
|
||||||
|
|
||||||
|
var cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null) return BadRequest(new {message = "Fallo al intentar encontrar tu usuario (puede que te hayas logeado desde otro dispositivo?)"});
|
||||||
|
|
||||||
|
bool ret = RepositorioNotificaciones.Singleton.HayNotis(cli.Dni);
|
||||||
|
return Ok(new {message = ret});
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPut("api/notificaciones")]
|
[HttpPut("api/notificaciones")]
|
||||||
public IActionResult MarcarComoLeido([FromHeader(Name = "Auth")]string Auth, NotificacionMarcarLeidoDto nota) {
|
public IActionResult MarcarComoLeido([FromHeader(Name = "Auth")]string Auth, NotificacionMarcarLeidoDto nota) {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title">Contrato</h5>
|
<h5 class="modal-title">Contrato</h5>
|
||||||
<button type="button" class="btn-close" onclick={onClose}></button>
|
<button type="button" class="btn-close" onclick={onClose} aria-label="Cerrar"></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
import { navigate } from "svelte-routing";
|
import { navigate } from "svelte-routing";
|
||||||
|
|
||||||
let isOpen: boolean = $state(false);
|
let isOpen: boolean = $state(false);
|
||||||
|
let hayNotis:boolean = $state(false);
|
||||||
|
|
||||||
const permisos = writable<Grupo[]>([]);
|
const permisos = writable<Grupo[]>([]);
|
||||||
const email = localStorage.getItem('email');
|
const email = localStorage.getItem('email');
|
||||||
@@ -38,8 +39,28 @@
|
|||||||
|
|
||||||
onMount( () => {
|
onMount( () => {
|
||||||
obtenerPermisos();
|
obtenerPermisos();
|
||||||
|
obtenerNotis();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
async function obtenerNotis() {
|
||||||
|
try {
|
||||||
|
const responce = await fetch($urlG+"/api/notificaciones/haySinLeer", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(responce.ok) {
|
||||||
|
let data = await responce.json();
|
||||||
|
hayNotis = data.message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function redirijir(path: string){
|
function redirijir(path: string){
|
||||||
navigate(path);
|
navigate(path);
|
||||||
}
|
}
|
||||||
@@ -70,8 +91,15 @@
|
|||||||
<img src="/toggle-right.svg" alt=""/>
|
<img src="/toggle-right.svg" alt=""/>
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
<button class="badge btn btn-info" onclick={()=>navigate("/notificaciones")}>
|
<button class="badge btn btn-info position-relative" onclick={()=>navigate("/notificaciones")}>
|
||||||
<img src="/bell.svg" alt="">
|
<img src="/bell.svg" alt="">
|
||||||
|
{#if hayNotis}
|
||||||
|
<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">
|
||||||
|
!
|
||||||
|
<span class="visually-hidden">unread messages</span>
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<NavbarToggler on:click={() => (isOpen = !isOpen)} />
|
<NavbarToggler on:click={() => (isOpen = !isOpen)} />
|
||||||
|
|||||||
@@ -127,8 +127,8 @@ public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
|
|||||||
Monto = cont.IdpropiedadNavigation.Monto,
|
Monto = cont.IdpropiedadNavigation.Monto,
|
||||||
Pagado = 0,
|
Pagado = 0,
|
||||||
};
|
};
|
||||||
can.Id = (con.Canons.Any()? con.Canons.Max(x=>x.Id) :0)+1;
|
can.Id = (con.Canons.Any()? con.Canons.Count() :0)+1+i;
|
||||||
can.Idcontratos.Add(cont);
|
|
||||||
|
|
||||||
con.Canons.Add(can);
|
con.Canons.Add(can);
|
||||||
cont.Idcanons.Add(can);
|
cont.Idcanons.Add(can);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Entidades.Dto;
|
|||||||
using Entidades;
|
using Entidades;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
using Org.BouncyCastle.Math.EC.Rfc7748;
|
||||||
|
|
||||||
namespace Modelo;
|
namespace Modelo;
|
||||||
|
|
||||||
@@ -35,4 +36,10 @@ public class RepositorioNotificaciones : RepositorioBase<RepositorioNotificacion
|
|||||||
.Where(x => x.Dnicliente == dni);
|
.Where(x => x.Dnicliente == dni);
|
||||||
return notis;
|
return notis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HayNotis(long dni) {
|
||||||
|
var con = Context;
|
||||||
|
bool hay = con.Notificaciones.Where(x=>x.Leido == false).Any();
|
||||||
|
return hay;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user