Exemple #1
0
        // GET: Departments/Edit
        public ActionResult Edit(string id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                Department department = DbFactory.Instance.context.Departments.Find(id);
                if (department == null)
                {
                    return(HttpNotFound());
                }
                List <Staff> staffList = StaffDepartmentDAO.FindAllStaffInDepartment(id);

                ViewBag.department = department.departmentName;

                ViewBag.staffIdContact = new SelectList(staffList, "staffId", "staffName", department.staffIdContact);
                return(View(department));
            }
            catch (Exception e)
            {
                return(View("~/Views/Shared/Error.cshtml"));
            }
        }
Exemple #2
0
        public ActionResult Edit(string departmentId, int staffIdContact, int departmentPhone, int departmentFax)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    DepartmentDAO.UpdateDepartmentContacts(departmentId, staffIdContact, departmentPhone, departmentFax);
                    return(RedirectToAction("Details"));
                }
                string userId = User.Identity.GetUserId();
                Staff  staff  = StaffDepartmentDAO.GetStaffByUserId(userId);

                Department department = DepartmentDAO.GetDepartmentByUserId(userId);

                List <Staff> staffList = StaffDepartmentDAO.FindAllStaffInDepartment(staff.departmentId);

                ViewBag.Department = staff.Department.departmentName;

                ViewBag.staffIdContact = new SelectList(staffList, "staffId", "staffName", department.staffIdContact);
                return(View(department));
            }
            catch (Exception e)
            {
                return(View("~/Views/Shared/Error.cshtml"));
            }
        }
        public ActionResult RoleDelegation()
        {
            string userId      = User.Identity.GetUserId();
            Staff  currentUser = StaffDepartmentDAO.GetStaffByUserId(userId);
            //Find all staff that are not DH and DR
            List <Staff> staffList      = StaffDepartmentDAO.FindAllStaffInDepartment(currentUser.Department.departmentId).Where(x => x.staffId != currentUser.Department.staffIdDH && x.staffId != currentUser.Department.staffIdDR).ToList();
            Staff        delegatedStaff = StaffDepartmentDAO.GetDelegatedStaff(currentUser.Department);

            //if no staff had been delegated for the period the viewbag will be null
            ViewBag.DelegatedStaff = delegatedStaff;

            return(View(staffList));
        }