コード例 #1
0
        public void Validator_rejects_invalid_month(string month)
        {
            var answers = new List <Answer>
            {
                new Answer
                {
                    QuestionId = "10001000_Month",
                    Value      = month
                },
                new Answer
                {
                    QuestionId = "10001000_Year",
                    Value      = "1980"
                }
            };
            var trusteeData = new TabularData
            {
                DataRows = new List <TabularDataRow>
                {
                    new TabularDataRow
                    {
                        Id      = "10001000",
                        Columns = new List <string>
                        {
                            "Ms A Trustee"
                        }
                    }
                }
            };

            var validationErrorDetails = TrusteeDateOfBirthValidator.ValidateTrusteeDatesOfBirth(trusteeData, answers);

            validationErrorDetails.Count.Should().Be(1);
            validationErrorDetails[0].ErrorMessage.Should().Be(DateOfBirthAnswerValidator.InvalidIncompleteDateOfBirthErrorMessage);
        }
コード例 #2
0
        public void Validator_rejects_year_with_less_than_4_digits(int year)
        {
            var answers = new List <Answer>
            {
                new Answer
                {
                    QuestionId = "10001000_Month",
                    Value      = "5"
                },
                new Answer
                {
                    QuestionId = "10001000_Year",
                    Value      = year.ToString()
                }
            };
            var trusteeData = new TabularData
            {
                DataRows = new List <TabularDataRow>
                {
                    new TabularDataRow
                    {
                        Id      = "10001000",
                        Columns = new List <string>
                        {
                            "Ms A Trustee"
                        }
                    }
                }
            };

            var validationErrorDetails = TrusteeDateOfBirthValidator.ValidateTrusteeDatesOfBirth(trusteeData, answers);

            validationErrorDetails.Count.Should().Be(1);
            validationErrorDetails[0].ErrorMessage.Should().Be(DateOfBirthAnswerValidator.DateOfBirthYearLengthErrorMessage);
        }
コード例 #3
0
        public void Validator_rejects_current_month_and_year()
        {
            var answers = new List <Answer>
            {
                new Answer
                {
                    QuestionId = "10001000_Month",
                    Value      = (DateTime.Now.Month).ToString()
                },
                new Answer
                {
                    QuestionId = "10001000_Year",
                    Value      = (DateTime.Now.Year).ToString()
                }
            };
            var trusteeData = new TabularData
            {
                DataRows = new List <TabularDataRow>
                {
                    new TabularDataRow
                    {
                        Id      = "10001000",
                        Columns = new List <string>
                        {
                            "Ms A Trustee"
                        }
                    }
                }
            };

            var validationErrorDetails = TrusteeDateOfBirthValidator.ValidateTrusteeDatesOfBirth(trusteeData, answers);

            validationErrorDetails.Count.Should().Be(1);
            validationErrorDetails[0].ErrorMessage.Should().Be(DateOfBirthAnswerValidator.DateOfBirthInFutureErrorMessage);
        }
        public async Task <IActionResult> TrusteesDobsConfirmed(ConfirmTrusteesDateOfBirthViewModel model)
        {
            var answers = _answerFormService.GetAnswersFromForm(HttpContext);

            var trusteesData = await _tabularDataRepository.GetTabularDataAnswer(model.ApplicationId, RoatpWorkflowQuestionTags.CharityCommissionTrustees);

            trusteesData = MapAnswersToTrusteesDob(trusteesData, answers);

            model.TrusteeDatesOfBirth = MapTrusteesDataToViewModel(trusteesData);

            if (model.TrusteeDatesOfBirth.Count == 0)
            {
                return(RedirectToAction("AddPeopleInControl", new { model.ApplicationId }));
            }

            model.ErrorMessages = TrusteeDateOfBirthValidator.ValidateTrusteeDatesOfBirth(trusteesData, answers);

            if (model.ErrorMessages != null & model.ErrorMessages.Count > 0)
            {
                return(View("~/Views/Roatp/WhosInControl/ConfirmTrusteesDob.cshtml", model));
            }

            var trusteeAnswers = new List <Answer>
            {
                new Answer
                {
                    QuestionId = RoatpYourOrganisationQuestionIdConstants.CharityCommissionTrustees,
                    Value      = JsonConvert.SerializeObject(trusteesData)
                },
                new Answer
                {
                    QuestionId = RoatpYourOrganisationQuestionIdConstants.CharityCommissionTrusteesConfirmed,
                    Value      = "Y"
                }
            };

            var updateTrusteesResult = await _qnaApiClient.UpdatePageAnswers(model.ApplicationId, RoatpWorkflowSequenceIds.YourOrganisation, RoatpWorkflowSectionIds.YourOrganisation.WhosInControl, RoatpWorkflowPageIds.WhosInControl.CharityCommissionTrustees, trusteeAnswers);

            if (!updateTrusteesResult.ValidationPassed)
            {
                return(RedirectToAction("ConfirmTrusteesDob", new { model.ApplicationId }));
            }
            else
            {
                var trusteeDobConfirmed = new List <Answer>
                {
                    new Answer
                    {
                        QuestionId = RoatpYourOrganisationQuestionIdConstants.CharityCommissionTrusteesDobConfirmed,
                        Value      = "Y"
                    }
                };

                await _qnaApiClient.UpdatePageAnswers(model.ApplicationId, RoatpWorkflowSequenceIds.YourOrganisation, RoatpWorkflowSectionIds.YourOrganisation.WhosInControl, RoatpWorkflowPageIds.WhosInControl.CharityCommissionTrusteesDob, trusteeDobConfirmed);
            }

            return(RedirectToAction("TaskList", "RoatpApplication", new { model.ApplicationId }));
        }
コード例 #5
0
        public void Validator_rejects_missing_date_of_birth_for_multiple_trustees()
        {
            var answers = new List <Answer>
            {
                new Answer
                {
                    QuestionId = "10002000_Month",
                    Value      = "11"
                },
                new Answer
                {
                    QuestionId = "10002000_Year",
                    Value      = "1980"
                }
            };
            var trusteeData = new TabularData
            {
                DataRows = new List <TabularDataRow>
                {
                    new TabularDataRow
                    {
                        Id      = "10002000",
                        Columns = new List <string>
                        {
                            "Ms A Trustee"
                        }
                    },
                    new TabularDataRow
                    {
                        Id      = "10003000",
                        Columns = new List <string>
                        {
                            "Mr B Trustee"
                        }
                    }
                }
            };

            var validationErrorDetails = TrusteeDateOfBirthValidator.ValidateTrusteeDatesOfBirth(trusteeData, answers);

            validationErrorDetails.Count.Should().Be(1);
            validationErrorDetails[0].ErrorMessage.Should().Be(DateOfBirthAnswerValidator.MissingDateOfBirthErrorMessage);
        }
コード例 #6
0
        public void Validator_rejects_missing_date_of_birth_for_single_trustee()
        {
            var answers     = new List <Answer>();
            var trusteeData = new TabularData
            {
                DataRows = new List <TabularDataRow>
                {
                    new TabularDataRow
                    {
                        Id      = "10001000",
                        Columns = new List <string>
                        {
                            "Ms A Trustee"
                        }
                    }
                }
            };

            var validationErrorDetails = TrusteeDateOfBirthValidator.ValidateTrusteeDatesOfBirth(trusteeData, answers);

            validationErrorDetails.Count.Should().Be(1);
            validationErrorDetails[0].ErrorMessage.Should().Be(DateOfBirthAnswerValidator.MissingDateOfBirthErrorMessage);
        }