Example #1
0
        public async Task <List <SubmittedApplicationAnswer> > ExtractAnswersForApplication(Guid applicationId)
        {
            _logger.LogInformation($"Extracting answers for application {applicationId}");
            var answers = new List <SubmittedApplicationAnswer>();

            try
            {
                var sections = await _qnaApiClient.GetAllSectionsForApplication(applicationId);

                if (sections != null)
                {
                    foreach (var section in sections)
                    {
                        var completedPages = section.QnAData.Pages.Where(pg => pg.Active && pg.Complete && !pg.NotRequired);

                        foreach (var page in completedPages)
                        {
                            var submittedPageAnswers = ExtractPageAnswers(applicationId, section.SequenceNo, section.SectionNo, page);
                            answers.AddRange(submittedPageAnswers);
                        }
                    }
                }
                //Extract QuestionId Y0-110 answer even if it is inactive, there is an issue setting answer active to false while adding orgnisation type answer to the tabular list as the last entry
                var hasPartnershipAnswersExtracted = answers.Any(answer => answer.QuestionId == QuestionIdPartnership);
                if (!hasPartnershipAnswersExtracted)
                {
                    await ExtractAnswers(applicationId, answers, QuestionIdPartnership, AddPartners);
                }

                //Extract QuestionId Y0-130 answer even if it is NotRequired case
                // In case where the organisation is a company or charity and we were not able to get PSCs from companies house
                // or charity commission then PSCs are entered manually.
                // However the NotRequired flag is set to true  on any of these filed TRUE UKRLPVerificationCompany, UKRLPVerificationCharity, UKRLPVerificationSoleTraderPartnership
                // and the answers could be missed.
                // Hence need to check again and populate this manual entry answers if they exists
                var hasAddPeopleInControlManualEntryAnswersExtracted = answers.Any(answer => answer.QuestionId == QuestionIdAddPeopleManualEntry);
                if (!hasAddPeopleInControlManualEntryAnswersExtracted)
                {
                    await ExtractAnswers(applicationId, answers, QuestionIdAddPeopleManualEntry, AddPeopleInControl);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Unable to extract answers for application {applicationId}");
                throw;
            }
            return(answers);
        }
Example #2
0
        public async Task <List <SubmittedApplicationAnswer> > ExtractAnswersForApplication(Guid applicationId)
        {
            _logger.LogDebug($"Extracting answers for application {applicationId}");

            var answers = new List <SubmittedApplicationAnswer>();

            var sections = await _qnaApiClient.GetAllSectionsForApplication(applicationId);

            if (sections != null)
            {
                foreach (var section in sections)
                {
                    var completedPages = section.QnAData.Pages.Where(pg => pg.Active && pg.Complete && !pg.NotRequired);

                    foreach (var page in completedPages)
                    {
                        var submittedPageAnswers = ExtractPageAnswers(applicationId, page);
                        answers.AddRange(submittedPageAnswers);
                    }
                }
            }

            return(answers);
        }