public ActionResult ChangeCollectionPoint()
        {
            string id    = User.Identity.GetUserId();
            var    staff = StaffDepartmentDAO.GetStaffByUserId(id);

            Department          dep     = staff.Department;
            DepartmentViewModel depView = StaffDepartmentDAO.ConvertDepartmentToDepartmentViewModel(dep);

            // Set CollectionPoint viewbag here!
            ViewBag.CollectionPoint = CollectionPointDAO.GetCollectionPoints();

            if (User.IsInRole("DH") || User.IsInRole("Temp DH"))
            {
                // get DR candidate list
                List <Staff> possibleList = StaffDepartmentDAO.FindPossibleDRList(staff);
                possibleList = possibleList == null ? new List <Staff>() : possibleList;
                Staff currentDR = StaffDepartmentDAO.FindDepartmentRole(staff.departmentId, "DR");

                // Set StaffList viewbag here!
                ViewBag.StaffList = new SelectList(
                    possibleList,
                    "staffId",
                    "staffName",
                    currentDR == null ? -1 : currentDR.staffId);
            }
            return(View(depView));
        }
Esempio n. 2
0
        public List <StaffViewModel> FindPossibleDRList()
        {
            string userId = User.Identity.GetUserId();
            var    s1     = StaffDepartmentDAO.GetStaffByUserId(userId);

            // find the possible DR candidate
            List <Staff> staffList = StaffDepartmentDAO.FindPossibleDRList(s1);

            // convert to plain data
            var svms = new List <StaffViewModel>();

            if (staffList != null)
            {
                foreach (var s in staffList)
                {
                    var svm = StaffDepartmentDAO.staffViewModelConverter(s);
                    svms.Add(svm);
                }
            }
            return(svms);
        }