public ActionResult RoleDelegation(List <Staff> Model, int?staffSelected, string removeAuthority, string submit, string startDate, string endDate, int?staffChosen) { string userId = User.Identity.GetUserId(); Staff currentUser = StaffDepartmentDAO.GetStaffByUserId(userId); // If remove authority button is clicked if (removeAuthority != null) { Staff delegatedStaff = StaffDepartmentDAO.GetDelegatedStaff(currentUser.Department); StaffDepartmentDAO.RemoveAuthority(delegatedStaff); // Return updated model //List<Staff> staffList = StaffDepartmentDAO.FindAllStaffInDepartment(currentUser.Department.departmentId).Where(x => x.staffId != currentUser.Department.staffIdDH && x.staffId != currentUser.Department.staffIdDR).ToList(); return(RedirectToAction("RoleDelegation")); } // If submit button is clicked if (submit != null && DateTime.TryParse(startDate, out DateTime d_start) && DateTime.TryParse(endDate, out DateTime d_end)) { StaffDepartmentDAO.GiveAuthority(staffChosen, d_start, d_end); return(RedirectToAction("RoleDelegation")); } ViewBag.DelegatedStaff = StaffDepartmentDAO.GetStaffByStaffId(staffSelected); return(View(Model)); }