private QuestionViewModel CreateGenericQuestionErrorPrompt(PromptAnswerViewModel promptAnswerViewModel, List <Question> questions,
                                                                   AmendmentOutcome outcome, Amendment amendment, Question thisQuestion)
        {
            var errorsPromptViewModel =
                new QuestionViewModel(questions, promptAnswerViewModel.CurrentIndex, outcome.ValidationErrors)
            {
                PupilDetails    = new PupilViewModel(amendment.Pupil),
                ShowConditional = thisQuestion.Answer.IsConditional
            };

            string actualMessage = string.Empty;

            foreach (var errorMessage in outcome.ValidationErrors)
            {
                foreach (var promptError in errorMessage.Value)
                {
                    ViewData.ModelState.AddModelError(errorMessage.Key, promptError);
                    actualMessage = promptError;
                }
            }

            if (!string.IsNullOrEmpty(actualMessage))
            {
                ViewData["errorMessage"] = actualMessage;
            }

            return(errorsPromptViewModel);
        }
        protected override void ApplyOutcomeToAmendment(Amendment amendment, AmendmentOutcome amendmentOutcome)
        {
            if (amendmentOutcome.IsComplete && amendmentOutcome.FurtherQuestions == null)
            {
                var isNonPlasc = _establishmentService.IsNonPlascEstablishment(amendment.CheckingWindow, new URN(amendment.URN));

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_ReasonDescription,
                                                   amendmentOutcome.ReasonDescription);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_ReasonCode,
                                                   amendmentOutcome.ReasonId);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_OutcomeDescription,
                                                   amendmentOutcome.OutcomeDescription);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_CountryOfOrigin,
                                                   GetFlattenedDisplayField(amendment, nameof(PupilCountryQuestion)));

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_NativeLanguage,
                                                   GetFlattenedDisplayField(amendment, nameof(PupilNativeLanguageQuestion)));

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_DateOfArrivalUk,
                                                   GetAnswer(amendment, nameof(ArrivalDateQuestion)).Value);

                if (isNonPlasc)
                {
                    amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_DateOnRoll,
                                                       GetAnswer(amendment, nameof(PupilDateOnRollQuestion)).Value);
                }
            }
        }
Beispiel #3
0
        protected override void ApplyOutcomeToAmendment(Amendment amendment, AmendmentOutcome amendmentOutcome)
        {
            if (amendmentOutcome.IsComplete && amendmentOutcome.FurtherQuestions == null)
            {
                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_ReasonDescription,
                                                   amendmentOutcome.ReasonDescription);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_ReasonCode,
                                                   amendmentOutcome.ReasonId);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_OutcomeDescription,
                                                   amendmentOutcome.OutcomeDescription);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_CountryLeftEnglandFor,
                                                   GetFlattenedDisplayField(amendment, nameof(CountryPupilLeftEnglandFor)));

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_DateOffRoll,
                                                   GetAnswer(amendment, nameof(PupilDateOffRollQuestion)).Value);

                if (HasAnswer(amendment, nameof(ExplainYourRequestQuestion)))
                {
                    amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_Detail,
                                                       GetAnswer(amendment, nameof(ExplainYourRequestQuestion)).Value);
                }
            }
        }
Beispiel #4
0
        protected override void ApplyOutcomeToAmendment(Amendment amendment, AmendmentOutcome amendmentOutcome)
        {
            if (amendmentOutcome.IsComplete && amendmentOutcome.FurtherQuestions == null)
            {
                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_ReasonDescription, amendmentOutcome.ReasonDescription);
                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_ReasonCode, amendmentOutcome.ReasonId);
                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_SubReasonDescription, amendmentOutcome.SubReason);
                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_OutcomeDescription, amendmentOutcome.OutcomeDescription);

                var dateOffRoll = GetAnswer(amendment, nameof(PupilDateOffRollQuestion)).Value;
                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_DateOffRoll, dateOffRoll);

                var explanation = GetAnswer(amendment, nameof(ExplainYourRequestQuestion)).Value;
                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_Detail, explanation);
            }
        }
        protected override void ApplyOutcomeToAmendment(Amendment amendment, AmendmentOutcome amendmentOutcome)
        {
            if (amendmentOutcome.IsComplete && amendmentOutcome.FurtherQuestions == null)
            {
                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_ReasonDescription,
                                                   amendmentOutcome.ReasonDescription);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_ReasonCode,
                                                   amendmentOutcome.ReasonId);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_SubReasonDescription,
                                                   amendmentOutcome.SubReason);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_OutcomeDescription,
                                                   amendmentOutcome.OutcomeDescription);
            }
        }
Beispiel #6
0
        protected override void ApplyOutcomeToAmendment(Amendment amendment, AmendmentOutcome amendmentOutcome)
        {
            if (amendmentOutcome.IsComplete && amendmentOutcome.FurtherQuestions == null)
            {
                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_ReasonDescription,
                                                   amendmentOutcome.ReasonDescription);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_ReasonCode,
                                                   amendmentOutcome.ReasonId);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_OutcomeDescription,
                                                   amendmentOutcome.OutcomeDescription);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_DateOffRoll,
                                                   GetAnswer(amendment, nameof(PupilDateOffRollQuestion)).Value);
            }
        }
Beispiel #7
0
        protected override void ApplyOutcomeToAmendment(Amendment amendment, AmendmentOutcome amendmentOutcome)
        {
            if (amendmentOutcome.IsComplete && amendmentOutcome.FurtherQuestions == null)
            {
                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_ReasonDescription,
                                                   amendmentOutcome.ReasonDescription);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_ReasonCode,
                                                   amendmentOutcome.ReasonId);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_OutcomeDescription,
                                                   amendmentOutcome.OutcomeDescription);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_LAESTABNumber,
                                                   GetAnswer(amendment, nameof(LaestabNumberQuestion)).Value);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_ExclusionDate,
                                                   GetAnswer(amendment, nameof(PupilExclusionDateQuestion)).Value);

                amendment.AmendmentDetail.SetField(RemovePupilAmendment.FIELD_Detail,
                                                   GetAnswer(amendment, nameof(ExplainYourRequestQuestion)).Value);
            }
        }
 private static bool GenericQuestionHasErrors(AmendmentOutcome outcome)
 {
     return(outcome.ValidationErrors != null && outcome.ValidationErrors.Count > 0);
 }