public ActionResult QuickNav() { string componentName = Request.Form["ComponentName"]; manager = new AssignmentWizardComponentManager(CurrentUser); IWizardBaseController componentToFind = manager.GetComponentByName(componentName); //start at the beginning while (manager.GetPreviousComponent() != null) { ; } //empty component name = start at the beginning (component selection) if (componentName.Length == 0) { return(RedirectToRoute(AssignmentWizardAreaRegistration.AssignmentWizardRoute, new { controller = "Home", action = "SelectComponent", assignmentId = manager.ActiveAssignmentId } )); } //from the beginning, find the component that we want to jump to bool found = false; while (!found) { if (manager.ActiveComponent == null) { found = true; } else if (manager.ActiveComponent.ControllerName.CompareTo(componentToFind.ControllerName) == 0) { found = true; } else { manager.GetNextComponent(); } } //redirect to the component return(RedirectToRoute(AssignmentWizardAreaRegistration.AssignmentWizardRoute, new { controller = componentToFind.ControllerName, action = "Index" } )); }
public virtual ActionResult Index() { Assignment = new Assignment(); manager = new AssignmentWizardComponentManager(CurrentUser); if (manager.ActiveAssignmentId != 0) { Assignment = db.Assignments.Find(manager.ActiveAssignmentId); } else { Assignment = new Assignment(); } SetUpViewBag(); return(View()); }
public HomeController() { ViewBag.AssignmentTypeRadioName = "AssignmentType"; manager = new AssignmentWizardComponentManager(CurrentUser); ViewBag.HideMail = OSBLE.Utility.DBHelper.GetAbstractCourseHideMailValue(ActiveCourseUser.AbstractCourseID); }
protected ActionResult PostBack(dynamic model) { manager = new AssignmentWizardComponentManager(CurrentUser); if (WasUpdateSuccessful) { //update the assignment ID. Probably not necessary when working //with existing assignments, but needed for new assignments. manager.ActiveAssignmentId = Assignment.ID; //Check manager context. If for some reason the user lost their //SESSION context, we need to detect this and redirect them //to a safe place. Otherwise, they will get an error when we //try to redirect them to a non-existant page if (manager.SelectedComponents.Count == 0) { return(RedirectToRoute(new { controller = "Home", action = "ContextLost", assignmentId = Assignment.ID })); } string errorPath = "Home"; string action = "ContextLost"; int id = Assignment.ID; IWizardBaseController comp = null; if (Request.Form.AllKeys.Contains(WizardNavButtons.PreviousButton.ToString())) { comp = manager.GetPreviousComponent(); if (Assignment.Type == AssignmentTypes.AnchoredDiscussion) { // we use deliverables to upload files for anchored discussion but we don't use it in the wizard if (comp.ControllerName == "Deliverables") { comp = manager.GetPreviousComponent(); // skip over the deliverables page } } errorPath = "Home"; action = "SelectComponent"; } else if (Request.Form.AllKeys.Contains(WizardNavButtons.NextButton.ToString())) { comp = manager.GetNextComponent(); if (Assignment.Type == AssignmentTypes.AnchoredDiscussion) { // we use deliverables to upload files for anchored discussion but we don't use it in the wizard if (comp != null && comp.ControllerName == "Deliverables") { comp = manager.GetNextComponent(); // skip over the deliverables page } } errorPath = "Home"; action = "Summary"; } else if (Request.Form.AllKeys.Contains(WizardNavButtons.SaveAndExitButton.ToString())) { return(RedirectToRoute("Default", new { controller = "Assignment", action = "index" } )); } else if (Request.Form.AllKeys.Contains("AutoGenFromPastButton")) { return(RedirectToRoute(AssignmentWizardAreaRegistration.AssignmentWizardRoute, new { controller = manager.ActiveComponent.ControllerName } )); } else { //not having any form keys means that we're using the QuickNav as it won't send back //any submit button data return(QuickNav()); } if (comp != null) { return(RedirectToRoute(AssignmentWizardAreaRegistration.AssignmentWizardRoute, new { controller = manager.ActiveComponent.ControllerName } )); } else { return(RedirectToRoute(AssignmentWizardAreaRegistration.AssignmentWizardRoute, new { controller = errorPath, action = action, assignmentId = id } )); } } try { SetUpViewBag(); } catch (Exception) { return(RedirectToRoute(new { controller = "Home", action = "ContextLost", assignmentId = Assignment.ID })); } return(View(model)); }