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 void RemoveStaffDelegation(StaffEF staff) { DepartmentEF department = staff.Department; department.AuthorityId = staff.StaffId; department.DelegationStartDate = null; department.DelegationEndDate = null; departmentEFF.SaveDepartment(department); }
public void CheckDelegation(DepartmentEF department) { long currentTimestamp = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; if (department.DelegationEndDate < currentTimestamp || department.DelegationEndDate == null) { StaffEF deptHead = FindDepartmentHead(department.DepartmentCode); RemoveStaffDelegation(deptHead); } }
public void DelegateStaff(ManageDelegationDTO manageDelegationDTO) { long delegationStartDate = Timestamp.dateToUnixTimestamp(manageDelegationDTO.DelegationStartDate); long delegationEndDate = Timestamp.dateToUnixTimestamp(manageDelegationDTO.DelegationEndDate) + 86399; DepartmentEF department = departmentEFF.FindDepartmentByCode(manageDelegationDTO.DepartmentCode); department.AuthorityId = manageDelegationDTO.AuthorityId; department.DelegationStartDate = delegationStartDate; department.DelegationEndDate = delegationEndDate; departmentEFF.SaveDepartment(department); }
public void SaveDepartment(DepartmentEF department) { var existingDepartment = context.Departments.Find(department.DepartmentCode); if (existingDepartment == null) { context.Departments.Add(department); } else { context.Entry(existingDepartment).CurrentValues.SetValues(department); } context.SaveChanges(); }
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" })); }
public List <StationeryRequestEF> FindRequestByDepartmentAndStatus(DepartmentEF department, string status) { List <StationeryRequestEF> pendingList = rndEFF.FindRequestsByDepartmentAndStatus(department.DepartmentCode, status); return(pendingList); }