Example #1
0
        private async Task <Section> GetParentCompanySection(Guid applicationId)
        {
            const string ParentCompanySectionTitle = "UK ultimate parent company";

            Section parentCompanySection = null;

            var hasParentCompanyTagValue = await _qnaApiClient.GetQuestionTag(applicationId, RoatpQnaConstants.QnaQuestionTags.HasParentCompany);

            if ("Yes".Equals(hasParentCompanyTagValue, StringComparison.OrdinalIgnoreCase))
            {
                parentCompanySection = await _qnaApiClient.GetSectionBySectionNo(applicationId,
                                                                                 RoatpQnaConstants.RoatpSequences.YourOrganisation,
                                                                                 RoatpQnaConstants.RoatpSections.YourOrganisation.OrganisationDetails);

                parentCompanySection.LinkTitle     = ParentCompanySectionTitle;
                parentCompanySection.Title         = ParentCompanySectionTitle;
                parentCompanySection.QnAData.Pages = parentCompanySection.QnAData.Pages?.Where(page =>
                                                                                               page.PageId == RoatpQnaConstants.RoatpSections.YourOrganisation.PageIds.ParentCompanyCheck ||
                                                                                               page.PageId == RoatpQnaConstants.RoatpSections.YourOrganisation.PageIds.ParentCompanyDetails)
                                                     .ToList();

                // This is a workaround for a single issue of layout. If any more go in, needs to be converted to a service
                // also contains code to remove an empty answer
                const string companyOrCharityNumberQuestionId = "YO-21";
                if (parentCompanySection?.QnAData?.Pages != null)
                {
                    var removeQuestions = new List <QnA.Api.Types.Page.Question>();
                    foreach (var question in parentCompanySection.QnAData.Pages.SelectMany(page =>
                                                                                           page.Questions.Where(question => question.QuestionId == companyOrCharityNumberQuestionId)))
                    {
                        question.Label = "Company or charity number";
                        removeQuestions.Add(question);
                    }

                    foreach (var parentCompanyDetails in parentCompanySection.QnAData.Pages.Where(page => page.PageId == RoatpQnaConstants.RoatpSections.YourOrganisation.PageIds.ParentCompanyDetails))
                    {
                        foreach (var x in from poa in parentCompanyDetails.PageOfAnswers from x in poa.Answers.Where(x => x.QuestionId == companyOrCharityNumberQuestionId) where string.IsNullOrEmpty(x.Value) select x)
                        {
                            foreach (var page in parentCompanySection.QnAData.Pages)
                            {
                                page.Questions.RemoveAll(pageToRemove => removeQuestions.Contains(pageToRemove));
                            }
                        }
                    }
                }
            }

            return(parentCompanySection);
        }
Example #2
0
        private async Task <Section> GetParentCompanySection(Guid applicationId)
        {
            const string ParentCompanySectionTitle = "UK ultimate parent company";

            Section parentCompanySection = null;

            var hasParentCompanyTagValue = await _qnaApiClient.GetQuestionTag(applicationId, RoatpQnaConstants.QnaQuestionTags.HasParentCompany);

            if ("Yes".Equals(hasParentCompanyTagValue, StringComparison.OrdinalIgnoreCase))
            {
                parentCompanySection = await _qnaApiClient.GetSectionBySectionNo(applicationId, RoatpQnaConstants.RoatpSequences.YourOrganisation, RoatpQnaConstants.RoatpSections.YourOrganisation.OrganisationDetails);

                parentCompanySection.LinkTitle     = ParentCompanySectionTitle;
                parentCompanySection.Title         = ParentCompanySectionTitle;
                parentCompanySection.QnAData.Pages = parentCompanySection.QnAData.Pages?.Where(page => page.PageId == RoatpQnaConstants.RoatpSections.YourOrganisation.PageIds.ParentCompanyCheck ||
                                                                                               page.PageId == RoatpQnaConstants.RoatpSections.YourOrganisation.PageIds.ParentCompanyDetails).ToList();
            }

            return(parentCompanySection);
        }