Пример #1
0
 public virtual ActionResult Index()
 {
     Assessment = new Assessment();
     Manager    = new AssessmentWizardComponentManager(CurrentUser);
     Assessment = Manager.ActiveAssessmentId != 0 ? db.Assessments.Find(Manager.ActiveAssessmentId) : new Assessment();
     SetUpViewBag();
     return(View());
 }
Пример #2
0
        public ActionResult QuickNav()
        {
            var componentName = Request.Form["ComponentName"];

            Manager = new AssessmentWizardComponentManager(CurrentUser);
            var 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(AssessmentWizardAreaRegistration.AssessmentWizardRoute,
                                       new
                {
                    controller = "Home",
                    action = "SelectComponent",
                    assignmentId = Manager.ActiveAssessmentId
                }
                                       ));
            }

            //from the beginning, find the component that we want to jump to
            var 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(AssessmentWizardAreaRegistration.AssessmentWizardRoute,
                                   new
            {
                controller = componentToFind.ControllerName,
                action = "Index"
            }
                                   ));
        }
Пример #3
0
        protected ActionResult PostBack(dynamic model)
        {
            Manager = new AssessmentWizardComponentManager(CurrentUser);
            if (WasUpdateSuccessful)
            {
                //update the assignment ID.  Probably not necessary when working
                //with existing assignments, but needed for new assignments.
                Manager.ActiveAssessmentId = Assessment.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 = Assessment.ID }));
                }

                var errorPath = "Home";
                var action    = "ContextLost";
                var id        = Assessment.ID;
                IWizardBaseController comp = null;
                if (Request.Form.AllKeys.Contains(WizardNavButtons.PreviousButton.ToString()))
                {
                    comp   = Manager.GetPreviousComponent();
                    action = "SelectComponent";
                }
                else if (Request.Form.AllKeys.Contains(WizardNavButtons.NextButton.ToString()))
                {
                    comp   = Manager.GetNextComponent();
                    action = "Summary";
                }
                else if (Request.Form.AllKeys.Contains(WizardNavButtons.SaveAndExitButton.ToString()))
                {
                    return(RedirectToRoute("Default",
                                           new
                    {
                        controller = "Assignment",
                        action = "index"
                    }
                                           ));
                }
                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(AssessmentWizardAreaRegistration.AssessmentWizardRoute,
                                           new
                    {
                        controller = Manager.ActiveComponent.ControllerName
                    }
                                           ));
                }
                return(RedirectToRoute(AssessmentWizardAreaRegistration.AssessmentWizardRoute,
                                       new
                {
                    controller = errorPath,
                    action = action,
                    assignmentId = id
                }
                                       ));
            }
            try
            {
                SetUpViewBag();
            }
            catch (Exception)
            {
                return(RedirectToRoute(new { controller = "Home", action = "ContextLost", assignmentId = Assessment.ID }));
            }
            return(View(model));
        }
Пример #4
0
 public HomeController()
 {
     ViewBag.AssessmentTypeRadioName = "AssessmentType";
     _manager = new AssessmentWizardComponentManager(CurrentUser);
 }