public ActionResult Schedule(IEnumerable <int> disbIdsToSchedule, String pickDate) { /* if (Session["IdEmployee"] == null || (String)Session["Role"] != "StockClerk") * return RedirectToAction("Login", "Home");*/ int IdStoreClerk = 1; if (Session["IdEmployee"] != null) { IdStoreClerk = (int)Session["IdEmployee"]; } if (disbIdsToSchedule != null) { // schedule for selected date by setting the date from the form DateTime SDate = DateTime.ParseExact(pickDate, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); _disbursementDAO.UpdateStatus(disbIdsToSchedule, 10, SDate, null); // add in notification here upon updating status foreach (var disbId in disbIdsToSchedule) { Disbursement targetDisbursement = _disbursementDAO.FindById(disbId); // Get Dep Rep Employee depRep = targetDisbursement.Department.Employees .Where(emp => emp.IdRole == 3) .FirstOrDefault(); String message = (targetDisbursement.DisbursementItems.ToList().All(i => i.UnitIssued >= i.UnitRequested)) ? $"Your department's request will be ready for collection on {SDate.ToString("dd/MM/yyyy")}." : $"Your department's request will be ready for collection on {SDate.ToString("dd/MM/yyyy")}. " + $"We are currently unable to prepare the full quantity of requested items from your department."; int notifId = _notificationDAO.CreateNotification(message); _notificationChannelDAO.SendNotification(IdStoreClerk, depRep.IdEmployee, notifId, DateTime.Now); var hub = GlobalHost.ConnectionManager.GetHubContext <ChatHub>(); hub.Clients.All.receiveNotification(depRep.IdEmployee); EmailClass emailClass = new EmailClass(); emailClass.SendTo(depRep.Email, "SSIS System Email", message); } } return(RedirectToAction("Disbursement")); }