public void UpdateDepartmentCollection(ManageCollectionDTO manageCollectionDTO) { if (manageCollectionDTO != null) { DepartmentEF department = departmentEFF.FindDepartmentByCode(manageCollectionDTO.Department); department.CollectionPointId = manageCollectionDTO.CollectionPointId; if (manageCollectionDTO.DepartmentRepId != null) { department.DepartmentRepresentativeId = manageCollectionDTO.DepartmentRepId; } departmentEFF.SaveDepartment(department); List <StaffEF> clerkList = staffService.FindStaffByRole(3); foreach (StaffEF clerk in clerkList) { if (clerk.Email != null) { string subject = "Update of Collection Point / Department Rep"; string body = department.DepartmentName + " has updated their collection point(" + department.CollectionPoint.Location + ", " + department.CollectionPoint.CollectionTime + ") and department representative(" + department.DepartmentRepresentative.Name + ")"; Email.SendEmail(clerk.Email, subject, body); } } } }
public ActionResult Index(string update) { if (update == "success") { ViewBag.note = "Department collection details has been updated"; } else if (update == "unchanged") { ViewBag.note = "No changes were made to the collection details"; } // Retrieve list of department staff and collection points StaffEF staff = staffService.GetStaff(); ViewBag.staff = staff; ViewBag.department = staff.Department; List <StaffEF> deptStaff = staffService.FindAllEmployeeByDepartmentCode(staff.DepartmentCode); List <CollectionPointEF> collectionPoints = deptService.FindAllCollectionPoints(); ManageCollectionDTO collectDTO = new ManageCollectionDTO(); // Display current department rep and collection point collectDTO.Department = staff.Department.DepartmentCode; collectDTO.CollectionPoints = collectionPoints; ViewBag.deptStaff = deptStaff; return(View(collectDTO)); }
// GET: /Collection/SetCollection public ActionResult SetCollection() { var manageCollectionDto = new ManageCollectionDTO(); var deptCode = Request.Cookies["Employee"]?["DeptCode"]; manageCollectionDto.CollectionPoint = _collectionRepo.GetCollectionPointByDeptCode(deptCode); manageCollectionDto.CollectionPoints = _collectionRepo.GetAll(); return(View(manageCollectionDto)); }
public ActionResult UpdateCollection(ManageCollectionDTO manageCollectionDto) { if (ModelState.IsValid) { var deptCode = Request.Cookies["Employee"]?["DeptCode"]; var department = _departmentRepo.GetById(deptCode); department.CollectionPointId = manageCollectionDto.DeptCollectionPointId; _departmentRepo.Update(department); ViewData["message"] = "Collection Point updated successfully"; return(PartialView("_SetCollection", department.CollectionPoint)); } return(RedirectToAction("SetCollection")); }
public ActionResult Index(ManageCollectionDTO manageCollectionDTO) { StaffEF staff = staffService.GetStaff(); DepartmentEF department = staff.Department; if (manageCollectionDTO.DepartmentRepId == department.DepartmentRepresentativeId && manageCollectionDTO.CollectionPointId == department.CollectionPointId) { return(RedirectToAction("Index", new { update = "unchanged" })); } else if (manageCollectionDTO.CollectionPointId == department.CollectionPointId && manageCollectionDTO.DepartmentRepId == null) { return(RedirectToAction("Index", new { update = "unchanged" })); } // Update collection point or department rep if changes are made deptService.UpdateDepartmentCollection(manageCollectionDTO); return(RedirectToAction("Index", new { update = "success" })); }