예제 #1
0
 public ActionResult Start()
 {
     NewAssignment newAssignment = new NewAssignment(ViewBag.EmployeeID);
     if (newAssignment.AvailableModules.Count == 0)
     {
         //TODO:  Redirect the user to a page that tells them that there are no available modules to choose from or let the SelectModule page handle it.
         return RedirectToAction("Dashboard", "Admin", new { EmployeeID = ViewBag.EmployeeID, CCApp = ViewBag.CCApp });
     }
     return View("SelectModule", newAssignment);
 }
예제 #2
0
        public ActionResult SelectStaff(NewAssignment assignment)
        {
            if (assignment.SelectedModuleId == null)
            {
                ModelState.AddModelError("SelectedModuleId", Literals.ModuleSelectionRequired);
            }

            if (!ModelState.IsValid)
            {
                return View("SelectModule", assignment);
            }

            if (assignment.Employee.ReportingScope < 2)
            {
                return RedirectToAction("Start", "Access", new { EmployeeID = ViewBag.EmployeeID, CCApp = ViewBag.CCApp });
            }

            //Check if any top level values have been changed and adjust accordingly.
            if (assignment.Zones != null &&
                !assignment.Zones.Any(z => z.Value == assignment.SelectedZoneCode))
            {
                assignment.SelectedZoneCode = null;
                assignment.SelectedDistrictCode = null;
            }
            if (assignment.Districts != null &&
                !assignment.Districts.Any(d => d.Value == assignment.SelectedDistrictCode))
            {
                assignment.SelectedDistrictCode = null;
            }

            //Pre-set values based on the employee's reporting scope and assigned area.
            if (assignment.Employee != null &&
                assignment.Employee.Area != null)
            {
                if (assignment.Employee.ReportingScope < 5 &&
                    assignment.Employee.Area.RegionID.HasValue)
                {
                    assignment.SelectedRegionId = assignment.Employee.Area.RegionID.Value.ToString();
                    assignment.RegionSelectionDisabled = true;
                }

                if (assignment.Employee.ReportingScope < 4 &&
                    assignment.Employee.Area.RegionID.HasValue &&
                    !string.IsNullOrEmpty(assignment.Employee.Area.ZoneCode))
                {
                    assignment.SelectedRegionId = assignment.Employee.Area.RegionID.Value.ToString();
                    assignment.SelectedZoneCode = assignment.Employee.Area.ZoneCode;
                    assignment.ZoneSelectionDisabled = true;
                }
                else if (assignment.Employee.ReportingScope < 4)
                {
                    RedirectToAction("Start", "Access", new { EmployeeID = ViewBag.EmployeeID, CCApp = ViewBag.CCApp });
                }

                if (assignment.Employee.ReportingScope < 3 &&
                    assignment.Employee.Area.RegionID.HasValue &&
                    !string.IsNullOrEmpty(assignment.Employee.Area.ZoneCode) &&
                    !string.IsNullOrEmpty(assignment.Employee.Area.DistrictCode))
                {
                    assignment.SelectedZoneCode = assignment.Employee.Area.ZoneCode;
                    assignment.SelectedDistrictCode = assignment.Employee.Area.DistrictCode;
                }
                else if (assignment.Employee.ReportingScope < 3)
                {
                    return RedirectToAction("Start", "Access", new { EmployeeID = ViewBag.EmployeeID, CCApp = ViewBag.CCApp });
                }
            }

            if (assignment.SelectedDistrictCode != null)
            {
                if (assignment.DueDate == DateTime.MinValue)
                {
                    assignment.DueDate = assignment.DefaultDueDate;
                }
                return View(assignment);
            }
            else
            {
                return View("SelectDistrict", assignment);
            }
        }
예제 #3
0
        public ActionResult CreateCategoryAssignment(NewAssignment assignment)
        {
            if (assignment.SelectedCategoryItems.Count <= 0)
            {
                ModelState.AddModelError("SelectedCategoryItems", Resources.Literals.ModuleGroupAssignmentIsRequired);
            }

            if (!ModelState.IsValid)
            {
                return View("SelectCategory", assignment);
            }

            try
            {
                ViewBag.Count = assignment.CreateCategoryAssignments();
                return View("Success", assignment);
            }
            catch (Exception)
            {
                ModelState.AddModelError("", "We're sorry, but we were unable to complete the assignment at this time.  Please try again or contact the system administrator.");
                return View("SelectCategory", assignment);
            }
        }
예제 #4
0
 public ActionResult OnSelectedZoneChanged(NewAssignment assignment)
 {
     return PartialView("_SelectDistrict", assignment);
 }
예제 #5
0
 public ActionResult OnSelectedRegionChanged(NewAssignment assignment)
 {
     return PartialView("_SelectZone", assignment);   
 }
예제 #6
0
        public ActionResult SelectCategory(NewAssignment assignment)
        {
            if (!Context.EmployeeCategoryEnabled)
            {
                return Start();
            }

            if (assignment.SelectedModuleId == null)
            {
                ModelState.AddModelError("SelectedModuleId", Literals.ModuleSelectionRequired);
            }

            if (!ModelState.IsValid)
            {
                return View("SelectModule", assignment);
            }

            if (assignment.DueDate == DateTime.MinValue)
            {
                assignment.DueDate = assignment.DefaultDueDate;
            }
            return View(assignment);
        }
예제 #7
0
        public ActionResult SelectGroup(NewAssignment assignment)
        {
            if (assignment.SelectedModuleId == null)
            {
                ModelState.AddModelError("SelectedModuleId", Literals.ModuleSelectionRequired);
            }

            if (!ModelState.IsValid)
            {
                return View("SelectModule", assignment);
            }

            if (assignment.DueDate == DateTime.MinValue)
            {
                assignment.DueDate = assignment.DefaultDueDate;
            }
            return View(assignment);
        }