public async Task Orchestrator_when_PeopleInControl_Page_builds_view_model_from_api()
        {
            var pageId            = GatewayPageIds.CriminalComplianceWhosInControlChecks.UnspentCriminalConvictions;
            var questionId        = "CC-40";
            var furtherQuestionId = "CC-40_1";

            _commonDetails.PageId = pageId;

            var criminalComplianceDetails = new CriminalComplianceCheckDetails
            {
                QuestionText      = "What is the question",
                Answer            = "Yes",
                QuestionId        = questionId,
                PageId            = pageId,
                FurtherAnswer     = "Lorem ipsum",
                FurtherQuestionId = furtherQuestionId
            };

            _criminalChecksApiClient.Setup(x => x.GetCriminalComplianceQuestionDetails(It.IsAny <Guid>(), It.IsAny <string>())).ReturnsAsync(criminalComplianceDetails);

            var viewModel = await _orchestrator.GetCriminalComplianceCheckViewModel(new GetCriminalComplianceCheckRequest(Guid.NewGuid(), pageId, "userId", "user"));

            viewModel.PageId.Should().Be(pageId);
            viewModel.Caption.Should().Be(RoatpGatewayConstants.Captions.PeopleInControlCriminalAndComplianceChecks);
            viewModel.QuestionText.Should().Be(criminalComplianceDetails.QuestionText);
            viewModel.Ukprn.Should().Be(_commonDetails.Ukprn);
            viewModel.ApplyLegalName.Should().Be(_commonDetails.LegalName);
            viewModel.ComplianceCheckQuestionId.Should().Be(questionId);
            viewModel.ComplianceCheckAnswer.Should().Be("Yes");
            viewModel.FurtherInformationQuestionId.Should().Be(furtherQuestionId);
            viewModel.FurtherInformationAnswer.Should().Be("Lorem ipsum");
        }
Esempio n. 2
0
        public async Task <IActionResult> GetCriminalComplianceQuestionDetails(Guid applicationId, string gatewayPageId)
        {
            var qnaPageDetails = _lookupService.GetQuestionDetailsForGatewayPageId(applicationId, gatewayPageId);

            var qnaPage = await _qnaApiClient.GetPageBySectionNo(applicationId, RoatpWorkflowSequenceIds.CriminalComplianceChecks,
                                                                 qnaPageDetails.SectionId,
                                                                 qnaPageDetails.PageId);

            var complianceChecksQuestion = qnaPage.Questions.FirstOrDefault(x => x.QuestionId == qnaPageDetails.QuestionId);

            var criminalComplianceCheckDetails = new CriminalComplianceCheckDetails {
                PageId = qnaPage.PageId
            };

            if (complianceChecksQuestion != null)
            {
                criminalComplianceCheckDetails.QuestionText = complianceChecksQuestion.Label;
                var pageOfAnswers = qnaPage.PageOfAnswers.FirstOrDefault();
                if (pageOfAnswers != null)
                {
                    var answer = pageOfAnswers.Answers.FirstOrDefault(x => x.QuestionId == qnaPageDetails.QuestionId);
                    criminalComplianceCheckDetails.QuestionId = answer.QuestionId;
                    criminalComplianceCheckDetails.Answer     = answer.Value;
                    PopulateFurtherQuestionIfAnswerMatches(complianceChecksQuestion, criminalComplianceCheckDetails, pageOfAnswers, answer);
                }
            }

            return(Ok(criminalComplianceCheckDetails));
        }
Esempio n. 3
0
 private static void PopulateFurtherQuestionIfAnswerMatches(Question complianceChecksQuestion,
                                                            CriminalComplianceCheckDetails criminalComplianceCheckDetails,
                                                            PageOfAnswers pageOfAnswers, Answer answer)
 {
     foreach (var option in complianceChecksQuestion.Input.Options)
     {
         if (option.FurtherQuestions != null && option.FurtherQuestions.Any() && option.Value == answer.Value)
         {
             var furtherInformationAnswer = pageOfAnswers.Answers.FirstOrDefault(x => x.QuestionId == option.FurtherQuestions[0]?.QuestionId);
             if (furtherInformationAnswer != null)
             {
                 criminalComplianceCheckDetails.FurtherQuestionId = furtherInformationAnswer.QuestionId;
                 criminalComplianceCheckDetails.FurtherAnswer     = furtherInformationAnswer.Value;
                 break;
             }
         }
     }
 }