コード例 #1
0
        /// <summary>
        /// Used to skip to final submission screens without validation,
        /// only after the user has been warned and yet they selected to "submit anyways" on the ValidationErrors.cshtml screen
        /// </summary>
        /// <returns></returns>
        public ActionResult SkipToFinalCert()
        {
            // *** RRB 4/7/16
            // Is there a reason why 'RedirectToAction' can't be used here ??
            // return RedirectToAction("Template", "Results", new { sectionId = sf.sectionId.ToString() });

            ResultsController rc = new ResultsController(formsRepo);

            rc.ControllerContext = ControllerContext;
            int sectionId = formsRepo.GetSectionByIdentifier("ADAP_cert").sectionId;

            return(rc.Template(sectionId));
        }
コード例 #2
0
        public ActionResult SaveStubApplication(FormCollection frmCllctn, TemplateItems itm)
        {
            //run normal save (update/add response variables based on form collection)
            ResultsController rc = new ResultsController(formsRepo);

            rc.ControllerContext = ControllerContext;
            ActionResult ar = rc.Save(frmCllctn, itm);

            //update or add UAS_User based on responses
            int formResultId = SessionHelper.SessionForm.formResultId;

            new AdapLAStubApp(formsRepo).UpdateUASFromStubApp(formResultId);

            return(ar);
        }
コード例 #3
0
        public bool FinalSubmit(FormCollection frmCllctn, TemplateItems itm)
        {
            int formResultId = SessionHelper.SessionForm.formResultId;

            //run save (update/add response variables based on form collection)
            ResultsController rc = new ResultsController(formsRepo);

            rc.ControllerContext = ControllerContext;
            rc.Save(frmCllctn, itm);

            //run status update
            int status = Convert.ToInt32(formsRepo.GetStatusDetailByMasterIdentifier(1, "NEEDS_REVIEW").sortOrder);

            AdapController ac = new AdapController(formsRepo);

            ac.ControllerContext = ControllerContext;
            ac.StatusUpdated("", formResultId, status, false);

            //return Redirect("~/ADAP");
            return(true);
        }
コード例 #4
0
        public ActionResult Validate(FormCollection frmCllctn, TemplateItems ti)
        {
            //save response from formCollection into the DB
            ResultsController rc = new ResultsController(formsRepo);

            rc.ControllerContext = ControllerContext;
            rc.Save(frmCllctn, ti);

            int formResultId = SessionHelper.SessionForm.formResultId;

            SessionHelper.SessionForm.sectionId = -1;

            //Run generic validation
            AdapValidationErrorsModel model = new AdapValidationErrorsModel();

            model.navMenuModel       = AJBoggs.Adap.Templates.TemplateMenus.getAdapNavMenuModel(SessionHelper.SessionForm, formsRepo);
            model.validationMessages = new List <string>();
            model.missingItemVariablesBySectionByPart = new Dictionary <int, Dictionary <int, List <string> > >();
            def_Forms        frm          = formsRepo.GetFormById(SessionHelper.SessionForm.formId);
            List <ValuePair> allResponses = CommonExport.GetDataByFormResultId(formResultId);
            SharedValidation sv           = new SharedValidation(allResponses);
            bool             invalid      = sv.DoGenericValidation(formsRepo, model, frm);

            //transfer generic validation results to an ADAP-specific model
            model.titlesOfMissingSubsectionsBySectionByPart = new Dictionary <int, Dictionary <int, List <string> > >();
            foreach (int prtId in model.missingItemVariablesBySectionByPart.Keys)
            {
                model.titlesOfMissingSubsectionsBySectionByPart.Add(prtId, new Dictionary <int, List <string> >());
                foreach (int sctId in model.missingItemVariablesBySectionByPart[prtId].Keys)
                {
                    def_Sections sct = formsRepo.GetSectionById(sctId);
                    formsRepo.SortSectionItems(sct);
                    List <int> ssSectionIds = new List <int>();
                    foreach (def_SectionItems si in sct.def_SectionItems.Where(si => si.subSectionId.HasValue))
                    {
                        ssSectionIds.Add(formsRepo.GetSubSectionById(si.subSectionId.Value).sectionId);
                    }

                    model.titlesOfMissingSubsectionsBySectionByPart[prtId].Add(sctId, new List <string>());
                    foreach (string itemVariableIdent in model.missingItemVariablesBySectionByPart[prtId][sctId])
                    {
                        //for each item variable identifier returned by generic validation,
                        //lookup the corresponding subsection's title for display on the ADAP "validation errors" screen
                        def_ItemVariables iv  = formsRepo.GetItemVariableByIdentifier(itemVariableIdent);
                        def_Items         itm = iv == null ? null : iv.def_Items;
                        def_SectionItems  si  = itm == null ? null : formsRepo.getSectionItemsForItem(itm).Where(sit => ssSectionIds.Contains(sit.sectionId)).FirstOrDefault();
                        def_Sections      sub = si == null ? null : si.def_Sections;
                        if (sub != null && !model.titlesOfMissingSubsectionsBySectionByPart[prtId][sctId].Contains(sub.title))
                        {
                            model.titlesOfMissingSubsectionsBySectionByPart[prtId][sctId].Add(sub.title);
                        }
                    }
                }
            }

            //run CO-ADAP one-off validation
            if (AdapCOOneOffValidation.RunOneOffValidation(sv, model))
            {
                invalid = true;
            }

            //return the validation errors screen if any errors were found
            //model.validationMessages could have some warnings even if no errors were found, in which case "invalid" would be false here
            if (invalid)
            {
                return(View("~/Views/COADAP/ValidationErrors.cshtml", model));
            }

            //if no problems were found, or if warnings were found but no errors, return the next section in the application
            if (model.validationMessages.Count == 0)
            {
                model.validationMessages.Add("No errors were found");
            }
            int sectionId = Convert.ToInt16(frmCllctn["navSectionId"]);

            return(rc.Template(sectionId, model.validationMessages));
        }