public async Task <IActionResult> EditPeopleInControl(Guid applicationId, int index) { var personTableData = await _tabularDataRepository.GetTabularDataAnswer(applicationId, RoatpWorkflowQuestionTags.AddPeopleInControl); if (personTableData != null) { if (index >= personTableData.DataRows.Count) { return(RedirectToAction("ConfirmPeopleInControl", new { applicationId })); } var person = personTableData.DataRows[index]; var name = person.Columns[0]; var dateOfBirth = person.Columns[1]; var model = new AddEditPeopleInControlViewModel { ApplicationId = applicationId, PersonInControlName = name, Index = index, Identifier = "person", PersonInControlDobMonth = DateOfBirthFormatter.GetMonthNumberFromShortDateOfBirth(dateOfBirth), PersonInControlDobYear = DateOfBirthFormatter.GetYearFromShortDateOfBirth(dateOfBirth), DateOfBirthOptional = false, GetHelpAction = "EditPeopleInControl", PageId = "EditPeopleInControl" }; PopulateGetHelpWithQuestion(model); return(View($"~/Views/Roatp/WhosInControl/EditPeopleInControl.cshtml", model)); } return(RedirectToAction("ConfirmPeopleInControl", new { applicationId })); }
private TabularData MapAnswersToTrusteesDob(TabularData trusteesData, List <Answer> answers) { if (trusteesData == null) { return(null); } if (trusteesData.HeadingTitles.Count < 2) { trusteesData.HeadingTitles.Add("Date of birth"); } foreach (var trustee in trusteesData.DataRows) { var dobMonthKey = $"{trustee.Id}_Month"; var dobYearKey = $"{trustee.Id}_Year"; var dobMonth = answers.FirstOrDefault(x => x.QuestionId == dobMonthKey); var dobYear = answers.FirstOrDefault(x => x.QuestionId == dobYearKey); if (dobMonth == null || dobYear == null) { break; } if (trustee.Columns.Count < 2) { trustee.Columns.Add(DateOfBirthFormatter.FormatDateOfBirth(dobMonth.Value, dobYear.Value)); } else { trustee.Columns[1] = DateOfBirthFormatter.FormatDateOfBirth(dobMonth.Value, dobYear.Value); } } return(trusteesData); }
private List <TrusteeDateOfBirth> MapTrusteesDataToViewModel(TabularData trusteeData) { var trusteeDatesOfBirth = new List <TrusteeDateOfBirth>(); if (trusteeData != null && trusteeData.DataRows != null) { foreach (var trustee in trusteeData.DataRows) { var trusteeDob = new TrusteeDateOfBirth { Id = trustee.Id, Name = trustee.Columns[0] }; if (trustee.Columns.Count > 1) { var shortDob = trustee.Columns[1]; trusteeDob.DobMonth = DateOfBirthFormatter.GetMonthNumberFromShortDateOfBirth(shortDob); trusteeDob.DobYear = DateOfBirthFormatter.GetYearFromShortDateOfBirth(shortDob); } trusteeDatesOfBirth.Add(trusteeDob); } } return(trusteeDatesOfBirth); }
public async Task <IActionResult> AddPeopleInControlDetails(AddEditPeopleInControlViewModel model) { var errorMessages = PeopleInControlValidator.Validate(model); if (errorMessages.Any()) { model.ErrorMessages = errorMessages; return(View("~/Views/Roatp/WhosInControl/AddPeopleInControl.cshtml", model)); } var whosInControlSection = await _qnaApiClient.GetSectionBySectionNo(model.ApplicationId, RoatpWorkflowSequenceIds.YourOrganisation, RoatpWorkflowSectionIds.YourOrganisation.WhosInControl); var personInControlData = await _tabularDataRepository.GetTabularDataAnswer(model.ApplicationId, RoatpWorkflowQuestionTags.AddPeopleInControl); var personInControl = new TabularDataRow { Id = Guid.NewGuid().ToString(), Columns = new List <string> { model.PersonInControlName, DateOfBirthFormatter.FormatDateOfBirth(model.PersonInControlDobMonth, model.PersonInControlDobYear) } }; if (personInControlData == null) { personInControlData = new TabularData { HeadingTitles = new List <string> { "Name", "Date of birth" }, DataRows = new List <TabularDataRow> { personInControl } }; var result = await _tabularDataRepository.SaveTabularDataAnswer( model.ApplicationId, whosInControlSection.Id, RoatpWorkflowPageIds.WhosInControl.AddPeopleInControl, RoatpYourOrganisationQuestionIdConstants.AddPeopleInControl, personInControlData); } else { var result = await _tabularDataRepository.UpsertTabularDataRecord( model.ApplicationId, whosInControlSection.Id, RoatpWorkflowPageIds.WhosInControl.AddPeopleInControl, RoatpYourOrganisationQuestionIdConstants.AddPeopleInControl, RoatpWorkflowQuestionTags.AddPeopleInControl, personInControl); } return(RedirectToAction("ConfirmPeopleInControl", new { model.ApplicationId })); }
public async Task <IActionResult> GetWhosInControlFromSubmitted(Guid applicationId) { _logger.LogInformation($"Retrieving submitted who's in control for application {applicationId}"); var peopleInControl = new List <PersonInControl>(); _logger.LogDebug($"Retrieving from [AddPeopleInControl] for submitted who's in control for application {applicationId}"); var pics = await _qnaApiClient.GetTabularDataByTag(applicationId, RoatpWorkflowQuestionTags.AddPeopleInControl); if (pics == null) { _logger.LogDebug($"Retrieving from [AddPartners] for submitted who's in control for application {applicationId}"); pics = await _qnaApiClient.GetTabularDataByTag(applicationId, RoatpWorkflowQuestionTags.AddPartners); } if (pics != null) { _logger.LogDebug($"Constructing list of who's in control from retrieved details for application {applicationId}"); if (pics?.DataRows != null) { foreach (var pic in pics.DataRows.Where(x => x.Columns.Any()).OrderBy(x => x.Columns[0])) { var picName = pic.Columns[0]; var picDob = string.Empty; if (pic.Columns.Any() && pic.Columns.Count >= 2) { picDob = pic.Columns[1]; } AddPersonToPeopleInControl(peopleInControl, picName, picDob); } } } else { _logger.LogDebug($"Retrieving from [soleTraderDob] for submitted who's in control for application {applicationId}"); var soleTraderDob = await _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.SoleTradeDob); if (!string.IsNullOrEmpty(soleTraderDob?.Value)) { var legalName = await _qnaApiClient.GetAnswerByTag(applicationId, RoatpWorkflowQuestionTags.UkrlpLegalName); var formattedDob = DateOfBirthFormatter.GetMonthYearDescription(soleTraderDob.Value); AddPersonToPeopleInControl(peopleInControl, legalName?.Value, formattedDob); } } return(Ok(peopleInControl)); }
public async Task <IActionResult> UpdatePartnerDetails(AddEditPeopleInControlViewModel model) { var errorMessages = PeopleInControlValidator.Validate(model); if (errorMessages.Any()) { model.ErrorMessages = errorMessages; return(View("~/Views/Roatp/WhosInControl/EditPartner.cshtml", model)); } var partnerTableData = await _tabularDataRepository.GetTabularDataAnswer(model.ApplicationId, RoatpWorkflowQuestionTags.AddPartners); if (partnerTableData != null) { var partner = new TabularDataRow { Columns = new List <string> { model.PersonInControlName } }; if (!model.DateOfBirthOptional) { partner.Columns.Add(DateOfBirthFormatter.FormatDateOfBirth(model.PersonInControlDobMonth, model.PersonInControlDobYear)); } else { partner.Columns.Add(string.Empty); } var whosInControlSection = await _qnaApiClient.GetSectionBySectionNo(model.ApplicationId, RoatpWorkflowSequenceIds.YourOrganisation, RoatpWorkflowSectionIds.YourOrganisation.WhosInControl); var result = await _tabularDataRepository.EditTabularDataRecord( model.ApplicationId, whosInControlSection.Id, RoatpWorkflowPageIds.WhosInControl.AddPartners, RoatpYourOrganisationQuestionIdConstants.AddPartners, RoatpWorkflowQuestionTags.AddPartners, partner, model.Index); } return(RedirectToAction("ConfirmPartners", new { model.ApplicationId })); }
public async Task <IActionResult> EditPartner(Guid applicationId, int index) { var partnerTableData = await _tabularDataRepository.GetTabularDataAnswer(applicationId, RoatpWorkflowQuestionTags.AddPartners); if (partnerTableData != null) { if (index >= partnerTableData.DataRows.Count) { return(RedirectToAction("ConfirmPartners", new { applicationId })); } var partner = partnerTableData.DataRows[index]; var model = new AddEditPeopleInControlViewModel { ApplicationId = applicationId, PersonInControlName = partner.Columns[0], Index = index, Identifier = "organisation", DateOfBirthOptional = true, GetHelpAction = "EditPartner", PageId = "EditPartner" }; if (partner.Columns.Count > 1 && !string.IsNullOrEmpty(partner.Columns[1])) { var dateOfBirth = partner.Columns[1]; model.PersonInControlDobMonth = DateOfBirthFormatter.GetMonthNumberFromShortDateOfBirth(dateOfBirth); model.PersonInControlDobYear = DateOfBirthFormatter.GetYearFromShortDateOfBirth(dateOfBirth); model.DateOfBirthOptional = false; model.Identifier = "individual"; } PopulateGetHelpWithQuestion(model); return(View($"~/Views/Roatp/WhosInControl/EditPartner.cshtml", model)); } return(RedirectToAction("ConfirmPartners", new { applicationId })); }
private void HydrateSectorDetailsWithFullNameJobRoleTimeInRole(AssessorPage page4NameRoleExperience, AssessorSectorDetails sectorDetails, SectorQuestionIds sectorPageIds) { if (page4NameRoleExperience?.Answers == null || !page4NameRoleExperience.Answers.Any()) { return; } sectorDetails.FirstName = _extractAnswerValueService.ExtractAnswerValueFromQuestionId(page4NameRoleExperience.Answers, sectorPageIds.FirstName); sectorDetails.LastName = _extractAnswerValueService.ExtractAnswerValueFromQuestionId(page4NameRoleExperience.Answers, sectorPageIds.LastName); sectorDetails.JobRole = _extractAnswerValueService.ExtractAnswerValueFromQuestionId(page4NameRoleExperience.Answers, sectorPageIds.JobRole); sectorDetails.TimeInRole = _extractAnswerValueService.ExtractAnswerValueFromQuestionId(page4NameRoleExperience.Answers, sectorPageIds.TimeInRole); sectorDetails.IsPartOfAnyOtherOrganisations = _extractAnswerValueService.ExtractAnswerValueFromQuestionId(page4NameRoleExperience.Answers, sectorPageIds.IsPartOfAnyOtherOrganisations); sectorDetails.OtherOrganisations = _extractAnswerValueService.ExtractFurtherQuestionAnswerValueFromQuestionId(page4NameRoleExperience, sectorPageIds.IsPartOfAnyOtherOrganisations); var dateOfBirth = _extractAnswerValueService.ExtractAnswerValueFromQuestionId(page4NameRoleExperience.Answers, sectorPageIds.DateOfBirth); sectorDetails.DateOfBirth = DateOfBirthFormatter.GetMonthYearDescription(dateOfBirth); sectorDetails.Email = _extractAnswerValueService.ExtractAnswerValueFromQuestionId(page4NameRoleExperience.Answers, sectorPageIds.Email); sectorDetails.ContactNumber = _extractAnswerValueService.ExtractAnswerValueFromQuestionId(page4NameRoleExperience.Answers, sectorPageIds.ContactNumber); }
public void Format_monthNumber_incorrect_input_converted_to_empty_string(string monthYearDescription, string expectedValue) { var formattedDob = DateOfBirthFormatter.GetMonthYearDescription(monthYearDescription); formattedDob.Should().Be(expectedValue); }
public void Format_monthNumber_comma_year_converted_to_mmm_yyyy(string monthYearDescription, string expectedValue) { var formattedDob = DateOfBirthFormatter.GetMonthYearDescription(monthYearDescription); formattedDob.Should().Be(expectedValue); }
public void Format_date_of_birth_rejects_non_numeric_values(string month, string year, string expectedValue) { var formattedDob = DateOfBirthFormatter.FormatDateOfBirth(month, year); formattedDob.Should().Be(expectedValue); }
public void Get_year_converts_short_date_to_year(string shortDate, string expectedValue) { var year = DateOfBirthFormatter.GetYearFromShortDateOfBirth(shortDate); year.Should().Be(expectedValue); }
public void Get_month_number_converts_short_date_to_month_number(string shortDate, string expectedValue) { var monthNumber = DateOfBirthFormatter.GetMonthNumberFromShortDateOfBirth(shortDate); monthNumber.Should().Be(expectedValue); }
public void Format_date_of_birth_converts_month_and_year_to_short_date(string month, string year, string expectedValue) { var formattedDob = DateOfBirthFormatter.FormatDateOfBirth(month, year); formattedDob.Should().Be(expectedValue); }