コード例 #1
0
        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);
        }
コード例 #2
0
        public ActionResult Index()
        {
            StaffEF staff = staffService.GetStaff();

            ViewBag.staff = staff;

            List <StaffEF> deptStaff = staffService.FindAllEmployeeByDepartmentCode(staff.DepartmentCode);

            ViewBag.deptStaff  = deptStaff;
            ViewBag.department = staff.Department;
            //retrieve current delegation
            ManageDelegationDTO manageDelegationDTO = new ManageDelegationDTO();

            manageDelegationDTO.DelegationStartDate = DateTime.UtcNow;
            manageDelegationDTO.DepartmentCode      = staff.DepartmentCode;

            return(View(manageDelegationDTO));
        }
コード例 #3
0
        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"));
        }