public ActionResult Index(ManageDelegationDTO manageDelegationDTO, string decision) { StaffEF staff = staffService.GetStaff(); ViewBag.staff = staff; List <StaffEF> deptStaff = staffService.FindAllEmployeeByDepartmentCode(staff.DepartmentCode); ViewBag.deptStaff = deptStaff; ViewBag.department = staff.Department; manageDelegationDTO.DelegationStartDate = DateTime.UtcNow; //update delegation and validate delegation start and end date if (decision == "Add Delegation") { if (staff.Department.AuthorityId != staff.StaffId) { ViewBag.note = "Please remove existing delegation before adding a new one"; return(View(manageDelegationDTO)); } if (manageDelegationDTO.DelegationEndDate.Date.CompareTo(manageDelegationDTO.DelegationStartDate.Date) < 0) { ViewBag.note = "Delegation End Date cannot be earlier than Delegation Start Date"; return(View(manageDelegationDTO)); } deptService.DelegateStaff(manageDelegationDTO); } else if (decision == "Remove Delegation") { deptService.RemoveStaffDelegation(staff); } return(RedirectToAction("Index")); }