public static List <notificacionCliente> getNotificaciones(int idCliente) { //buscar cliente CabspotDB db = new CabspotDB(); clientes cliente = db.clientes.Find(idCliente); if (cliente != null) { //buscar notificaciones para ese cliente //var notificaciones = db.notificacionCliente.Where(x => x.idCliente == cliente.idCliente).ToList(); var notificaciones = from n in db.notificacionCliente where n.idCliente == idCliente && !n.enviada select n; //var notificacionesReturn = from n in db.notificacionCliente where n.idCliente == idCliente && !n.enviada select n.tramaJson; List <notificacionCliente> notificacionesReturn = new List <notificacionCliente>(); if (notificaciones.Count() > 0) { //marcar notificaciones como leidas try { foreach (var n in notificaciones) { n.enviada = true; db.Entry(n).State = EntityState.Modified; notificacionesReturn.Add(n); } db.SaveChanges(); } catch (Exception e) { return(null); } //devolver las notificaciones return(notificacionesReturn.ToList()); } else { return(null); } } else { return(null); } }
public static List <notificacionTaxista> getNotificacionesTaxista(int idTaxista) { //buscar taxista taxistas taxista = db.taxistas.Find(idTaxista); if (taxista != null) { //buscar notificaciones para ese cliente var notificacionesUpdate = from n in db.notificacionTaxista where n.idTaxista == idTaxista && !n.enviada select n; List <notificacionTaxista> notificacionesReturn = new List <notificacionTaxista>(); if (notificacionesUpdate.Count() > 0) { //marcar notificaciones como leidas try { foreach (var n in notificacionesUpdate) { n.enviada = true; db.Entry(n).State = EntityState.Modified; notificacionesReturn.Add(n); } db.SaveChanges(); } catch (Exception e) { return(null); } //devolver las notificaciones return(notificacionesReturn); } else { return(null); } } else { return(null); } }