public ActionResult NotifIndex(SearchModelDate searchModel) { ViewBag.Home = true; if (Session["UserId"] != null) { int UserId = (int)Session["UserId"]; ViewHome model = new ViewHome(); DateTime?startDate = null; DateTime?endDate = null; if (!string.IsNullOrEmpty(searchModel.startDate)) { startDate = DateTime.ParseExact(searchModel.startDate, "dd.MM.yyyy", CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(searchModel.endDate)) { endDate = DateTime.ParseExact(searchModel.endDate, "dd.MM.yyyy", CultureInfo.InvariantCulture); } model.Notifications = db.Notifications.Where(av => (av.UserId == UserId) && (startDate != null ? av.AddingDate >= startDate : true) && (endDate != null ? av.AddingDate <= endDate : true) ).OrderByDescending(av => av.AddingDate).ToList(); model.SearchDate = searchModel; return(View(model)); } else { return(RedirectToAction("login", "home")); } }
public ActionResult NotifDetails(SearchModelDate searchModel) { ViewBag.Home = true; if (searchModel.employeeId != null) { if (ModelState.IsValid) { Notifications notif = db.Notifications.Find(searchModel.notificationId); notif.Status = false; db.Entry(notif).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("DrvInpIndex", "Inputs", new { searchModel.employeeId })); } else { return(RedirectToAction("NotifIndex")); } }