Files
AlquilaFacil/Modelo/RepositorioNotificaciones.cs

45 lines
1.3 KiB
C#

using System.Security.Cryptography;
using System.Text;
using Entidades.Dto;
using Entidades;
using Microsoft.EntityFrameworkCore;
using System.Collections.Concurrent;
using Org.BouncyCastle.Math.EC.Rfc7748;
namespace Modelo;
public class RepositorioNotificaciones : RepositorioBase<RepositorioNotificaciones> {
public bool MarcarComoLeido(long dni, DateTime? fecha) {
if (fecha == null) return false;
var con = Context;
Notificacione? noti = con.Notificaciones.FirstOrDefault(x=> x.Dnicliente == dni && x.Fecha == fecha);
if (noti == null) return false;
noti.Leido = true;
return Guardar(con);
}
public bool AltaNotificacion(Notificacione n) {
var con = Context;
con.Notificaciones.Add(n);
return Guardar(con);
}
public IQueryable<Notificacione> ObtenerNotificacionesDeUsuario(long dni) {
var con = Context;
var notis = con.Notificaciones
.Include(x=>x.IdpropiedadNavigation)
.Include(x=>x.DniremitenteNavigation)
.Where(x => x.Dnicliente == dni);
return notis;
}
public bool HayNotis(long dni) {
var con = Context;
bool hay = con.Notificaciones.Where(x=>x.Leido == false).Any();
return hay;
}
}