//Las notificaciones asociadas a los registros no se crean al crear el registro //Antes de listar en pantalla los vencimientos, se le asocian la notificaciones a los registros que no la tienen private void ActualizarNotificacionesVencimientos() { using (CursosDbContext db = new CursosDbContext()) { var rcSinNotificacioneAsociadas = db.RegistroCapacitacion.Where(r => !db.NotificacionVencimientos.Any(n => n.RegistroCapacitacionID == r.RegistroCapacitacionID)).ToList(); if (rcSinNotificacioneAsociadas.Count > 0) { foreach (var r in rcSinNotificacioneAsociadas) { var n = new NotificacionVencimiento { Estado = EstadoNotificacionVencimiento.NotificacionPendiente, RegistroCapacitacion = r, Fecha = DateTime.Now }; db.NotificacionVencimientos.Add(n); } db.SaveChanges(); } } }
public ActionResult DeleteConfirmed(int id) { NotificacionVencimiento notificacionVencimiento = db.NotificacionVencimientos.Find(id); db.NotificacionVencimientos.Remove(notificacionVencimiento); db.SaveChanges(); return(RedirectToAction("Index")); }
public void ActualizarNotificacionesVencimientos() { var registrosPorVencer = db.NotificacionVencimientos.Where(r => r.Estado == EstadoNotificacionVencimiento.NotificacionPendiente); //registrosPorVencer = registrosPorVencer.Where(r => r.NotificarRegistroPorVencer); //var registrosPorVencer = db.RegistroCapacitacion.Where(r => r.FechaVencimiento >= fechaInicioControlVencimientos && // r.FechaVencimiento >= r.FechaVencimiento.AddDays(diasAnticipacionAviso)).ToList(); //List<RegistroCapacitacion> registrosPorVencer = new List<RegistroCapacitacion>(); foreach (var registroPorVencer in registrosPorVencer.ToList()) { NotificacionVencimiento notificacion = new NotificacionVencimiento { RegistroCapacitacion = registroPorVencer.RegistroCapacitacion, MailNotificacionVencimiento = string.Empty, Estado = EstadoNotificacionVencimiento.NotificacionPendiente }; db.NotificacionVencimientos.Add(notificacion); } //si se agregó alguna notificación de vencimiento if (registrosPorVencer.ToList().Count > 0) { db.SaveChanges(); } /* * var registrosPorVencer = db.RegistroCapacitacion.AsQueryable(); * * registrosPorVencer = registrosPorVencer.Where(r => r.NotificarRegistroPorVencer); * * //var registrosPorVencer = db.RegistroCapacitacion.Where(r => r.FechaVencimiento >= fechaInicioControlVencimientos && * // r.FechaVencimiento >= r.FechaVencimiento.AddDays(diasAnticipacionAviso)).ToList(); * * //List<RegistroCapacitacion> registrosPorVencer = new List<RegistroCapacitacion>(); * * foreach (var registroPorVencer in registrosPorVencer.ToList()) * { * NotificacionVencimiento notificacion = new NotificacionVencimiento * { * RegistroCapacitacion = registroPorVencer, * MailNotificacionVencimiento = string.Empty, * Estado = EstadoNotificacionVencimiento.NotificacionPendiente * }; * * db.NotificacionVencimientos.Add(notificacion); * } * * //si se agregó alguna notificación de vencimiento * if (registrosPorVencer.ToList().Count > 0) * db.SaveChanges(); */ }
public ActionResult Edit([Bind(Include = "NotificacionVencimientoID,MailNotificacionVencimiento,RegistroCapacitacionID")] NotificacionVencimiento notificacionVencimiento) { if (ModelState.IsValid) { db.Entry(notificacionVencimiento).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RegistroCapacitacionID = new SelectList(db.RegistroCapacitacion, "RegistroCapacitacionID", "UsuarioModificacion", notificacionVencimiento.RegistroCapacitacionID); return(View(notificacionVencimiento)); }
// GET: NotificacionesVencimientos/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NotificacionVencimiento notificacionVencimiento = db.NotificacionVencimientos.Find(id); if (notificacionVencimiento == null) { return(HttpNotFound()); } return(View(notificacionVencimiento)); }
// GET: NotificacionesVencimientos/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NotificacionVencimiento notificacionVencimiento = db.NotificacionVencimientos.Find(id); if (notificacionVencimiento == null) { return(HttpNotFound()); } ViewBag.RegistroCapacitacionID = new SelectList(db.RegistroCapacitacion, "RegistroCapacitacionID", "UsuarioModificacion", notificacionVencimiento.RegistroCapacitacionID); return(View(notificacionVencimiento)); }
private string AgregarATableCapacitados(NotificacionVencimiento n, string backgroundColor) { string html = string.Empty; html += string.Format("<tr style='background-color: {0}'>", backgroundColor); html += "<td>"; html += n.RegistroCapacitacion.Capacitado.NombreCompleto; html += "</td>"; html += "<td>"; html += n.RegistroCapacitacion.Capacitado.DocumentoCompleto; html += "</td>"; html += "<td>"; html += n.RegistroCapacitacion.Jornada.Curso.Descripcion; html += "</td>"; html += "<td>"; html += n.RegistroCapacitacion.FechaVencimiento.ToShortDateString(); html += "</td>"; html += "</tr> "; return(html); }