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 })); }
public async Task <IActionResult> ConfirmTrusteesDob(Guid applicationId) { var trusteesData = await _tabularDataRepository.GetTabularDataAnswer(applicationId, RoatpWorkflowQuestionTags.CharityCommissionTrustees); var model = new ConfirmTrusteesDateOfBirthViewModel { ApplicationId = applicationId, TrusteeDatesOfBirth = MapTrusteesDataToViewModel(trusteesData) }; PopulateGetHelpWithQuestion(model); return(View("~/Views/Roatp/WhosInControl/ConfirmTrusteesDob.cshtml", model)); }