public void TestSetup() { _qnaApiClient = new Mock <IInternalQnaApiClient>(); _assessorSequenceService = new Mock <IAssessorSequenceService>(); _assessorLookupService = new AssessorLookupService(); _assessorPageService = new AssessorPageService(_qnaApiClient.Object, _assessorSequenceService.Object, _assessorLookupService); _assessorSequenceService.Setup(x => x.IsValidSequenceNumber(It.IsAny <int>())).Returns(true); var section = new ApplicationSection { ApplicationId = _applicationId, SequenceId = _sequenceNumber, SectionId = _sectionNumber, QnAData = new QnAData { Pages = new List <Page> { GenerateQnAPage(_firstPageId), GenerateQnAPage(_lastPageId) } } }; _qnaApiClient.Setup(x => x.GetSectionBySectionNo(section.ApplicationId, section.SequenceId, section.SectionId)).ReturnsAsync(section); _qnaApiClient.Setup(x => x.SkipPageBySectionNo(section.ApplicationId, section.SequenceId, section.SectionId, _firstPageId)).ReturnsAsync(new SkipPageResponse { NextAction = NextAction.NextPage, NextActionId = _lastPageId }); _qnaApiClient.Setup(x => x.SkipPageBySectionNo(section.ApplicationId, section.SequenceId, section.SectionId, _lastPageId)).ReturnsAsync(new SkipPageResponse { NextAction = NextAction.ReturnToSection }); }
private async Task CopyWorkflows(CancellationToken cancellationToken, Data.Entities.Application newApplication) { var workflowSequences = await _dataContext.WorkflowSequences.AsNoTracking() .Where(seq => seq.WorkflowId == newApplication.WorkflowId).ToListAsync(cancellationToken); var groupedSequences = workflowSequences.GroupBy(seq => new { seq.SequenceNo, seq.IsActive }).ToList(); var newApplicationSequences = groupedSequences.Select(seq => new ApplicationSequence { ApplicationId = newApplication.Id, SequenceNo = seq.Key.SequenceNo, IsActive = seq.Key.IsActive }).ToList(); await _dataContext.ApplicationSequences.AddRangeAsync(newApplicationSequences, cancellationToken); _logger.LogInformation($"Created ApplicationSequence entities for Application: {newApplication.Id}"); var sectionIds = groupedSequences.SelectMany(seq => seq).Select(seq => seq.SectionId).ToList(); var workflowSections = await _dataContext.WorkflowSections.AsNoTracking() .Where(sec => sectionIds.Contains(sec.Id)).ToListAsync(cancellationToken: cancellationToken); var newApplicationSections = new List <ApplicationSection>(); foreach (var sequence in groupedSequences) { var applicationSequence = newApplicationSequences.Single(appSeq => appSeq.SequenceNo == sequence.Key.SequenceNo); foreach (var sectionDetails in sequence) { var workflowSection = workflowSections.Single(wSec => wSec.Id == sectionDetails.SectionId); var newSection = new ApplicationSection { Id = Guid.NewGuid(), SequenceId = applicationSequence.Id, Title = workflowSection.Title, LinkTitle = workflowSection.LinkTitle, ApplicationId = newApplication.Id, DisplayType = workflowSection.DisplayType, QnAData = workflowSection.QnAData, SectionNo = sectionDetails.SectionNo, SequenceNo = sectionDetails.SequenceNo }; foreach (var page in newSection.QnAData.Pages) { page.SectionId = newSection.Id; page.SequenceId = newSection.SequenceId; } newApplicationSections.Add(newSection); } } await _dataContext.ApplicationSections.AddRangeAsync(newApplicationSections, cancellationToken); _logger.LogInformation($"Created ApplicationSection entities for Application: {newApplication.Id}"); }
public IdentityClient() { Application = new ApplicationSection(); Authentication = new AuthenticationSection(); Account = new AccountSection(); Email = new EmailSection(); }
private void RemovePages(Data.Entities.Application application, ApplicationSection section) { var applicationData = JObject.Parse(application.ApplicationData); RemoveInactivePages(section); RemovePagesBasedOnNotRequiredConditions(section, applicationData); }
private static int SectionCompletedQuestionsCount(ApplicationSection section) { int answeredQuestions = 0; var pages = section.QnAData.Pages.Where(p => p.NotRequired == false); foreach (var page in pages) { var questionIds = page.Questions.Select(x => x.QuestionId); foreach (var questionId in questionIds) { foreach (var pageOfAnswers in page.PageOfAnswers) { var matchedAnswer = pageOfAnswers.Answers.FirstOrDefault(y => y.QuestionId == questionId); if (matchedAnswer != null && !String.IsNullOrEmpty(matchedAnswer.Value)) { answeredQuestions++; break; } } } } return(answeredQuestions); }
private static void CreateSection(CrudOperationData jsonObject, StringBuilder sb, ApplicationSection section) { if (section.Parameters.ContainsKey("nodescription")) { return; } var sectionHeader = OpenSection(section); var displayables = DisplayableUtil.GetDisplayable <IApplicationAttributeDisplayable>( typeof(IApplicationAttributeDisplayable), section.Displayables, true, true); if (section.Id == "specification") { sb.Append(sectionHeader); HandleSpecifications(sb, (string)jsonObject.GetAttribute(section.Id), section); return; } var st = DoHandleDisplayables(jsonObject, displayables); if (!String.IsNullOrEmpty(st)) { sb.Append(sectionHeader); sb.Append(st); } }
public static string OpenSection(ApplicationSection section) { var sb = new StringBuilder(); sb.AppendLine(SectionSeparator); string sectionTitle; if (!section.Parameters.TryGetValue("detaildescription", out sectionTitle)) { if (section.Header != null) { sectionTitle = section.Header.Label; } else { ExceptionUtil.InvalidOperation( "unable to determine section title. Please specify parameter detaildescription or a header to section {0}", section.Id); } } if (!String.IsNullOrWhiteSpace(sectionTitle)) { sb.AppendLine(sectionTitle); sb.AppendLine(); } return(sb.ToString()); }
public async Task <IActionResult> Section(Guid Id, int sequenceNo, int sectionNo) { var section = await _qnaApiClient.GetSectionBySectionNo(Id, sequenceNo, sectionNo); var applicationSection = new ApplicationSection { Section = section, Id = Id }; applicationSection.SequenceNo = sequenceNo; applicationSection.PageContext = OrganisationName; switch (section?.DisplayType) { case null: case SectionDisplayType.Pages: return(View("~/Views/Application/Section.cshtml", applicationSection)); case SectionDisplayType.Questions: return(View("~/Views/Application/Section.cshtml", applicationSection)); case SectionDisplayType.PagesWithSections: return(View("~/Views/Application/PagesWithSections.cshtml", applicationSection)); default: throw new BadRequestException("Section does not have a valid DisplayType"); } }
public async Task Then_feedback_entry_is_inserted() { var createdDateTime = new DateTime(2018, 2, 3); SystemTime.UtcNow = () => createdDateTime; var dataContext = DataContextHelpers.GetInMemoryDataContext(); var applicationId = Guid.NewGuid(); var sectionId = Guid.NewGuid(); var section = new ApplicationSection { ApplicationId = applicationId, Id = sectionId, QnAData = new QnAData { Pages = new List <Page> { new Page { PageId = "1" } } } }; await dataContext.ApplicationSections.AddAsync(section); await dataContext.SaveChangesAsync(); var handler = new UpsertFeedbackHandler(dataContext); var newFeedbackId = Guid.NewGuid(); await handler.Handle(new UpsertFeedbackRequest(applicationId, sectionId, "1", new Feedback { Date = DateTime.UtcNow, From = "Dave", Id = newFeedbackId, Message = "Feedback message" }), CancellationToken.None); var updatedSection = await dataContext.ApplicationSections.SingleAsync(); var updatedPage = updatedSection.QnAData.Pages[0]; updatedPage.Feedback.Should().NotBeNullOrEmpty(); updatedPage.Feedback.Count.Should().Be(1); var insertedFeedback = updatedPage.Feedback[0]; insertedFeedback.Date.Should().Be(createdDateTime); insertedFeedback.From.Should().Be("Dave"); insertedFeedback.Id.Should().Be(newFeedbackId); insertedFeedback.Message.Should().Be("Feedback message"); insertedFeedback.IsNew.Should().BeTrue(); insertedFeedback.IsCompleted.Should().BeFalse(); }
internal IdentityClient(IdentityClientConfiguration config) { Configuration = config; HttpHelper.Configure(config.ApplicationId, config.Address); Application = new ApplicationSection(); Authentication = new AuthenticationSection(); Email = new EmailSection(); }
private static bool?YesNoValueForPageQuestion(ApplicationSection section, string pageId, string questionId) { var value = ValueForPageQuestion(section, pageId, questionId); return(value != null ? value.ToUpper() == "YES" : ( bool?)null); }
public async Task Subsequent_nextAction_further_down_the_branch_is_returned() { var pageThreeNextAction = new Next { Action = "NextPage", ReturnId = "4" }; var section = new ApplicationSection { ApplicationId = ApplicationId, QnAData = new QnAData { Pages = new List <Page> { new Page { PageId = "2", NotRequiredConditions = new List <NotRequiredCondition> { new NotRequiredCondition() { Field = "OrgType", IsOneOf = new string[] { "OrgType1", "OrgType2" } } }, Next = new List <Next> { new Next { Action = "NextPage", ReturnId = "3" } } }, new Page { PageId = "3", NotRequiredConditions = new List <NotRequiredCondition> { new NotRequiredCondition() { Field = "OrgType", IsOneOf = new string[] { "OrgType1" } } }, Next = new List <Next> { pageThreeNextAction } }, new Page { PageId = "4", NotRequiredConditions = null } } } }; var applicationData = JObject.Parse(ApplicationDataJson); var nextActionAfterFindingNextAction = SetAnswersBase.FindNextRequiredAction(section, NextAction, applicationData); nextActionAfterFindingNextAction.Should().BeEquivalentTo(pageThreeNextAction); }
public ApplicationSection ProcessPagesInSectionsForStatusText(ApplicationSection selectedSection) { foreach (var page in selectedSection.QnAData.Pages.Where(x => x.DisplayType == SectionDisplayType.PagesWithSections)) { page.StatusText = AssociatedPagesWithSectionStatus(page, selectedSection.QnAData, true); } return(selectedSection); }
private static string ValueForPageQuestion(ApplicationSection section, string pageId, string questionId) { var page = section?.QnAData?.Pages.FirstOrDefault(p => p.Active && p.PageId == pageId); var pageOfAnswers = page?.PageOfAnswers; return(pageOfAnswers == null ? null : (from answers in pageOfAnswers from answer in answers.Answers where answer.QuestionId == questionId select answer.Value).FirstOrDefault()); }
public void And_one_of_the_nextactions_has_condition_null_Then_that_action_is_returned() { var actionWithNoCondition = new Next { Action = "NextPage", ReturnId = "3", Conditions = null }; var section = new ApplicationSection { ApplicationId = ApplicationId, QnAData = new QnAData { Pages = new List <Page> { new Page { PageId = "2", NotRequiredConditions = new List <NotRequiredCondition> { new NotRequiredCondition() { Field = "OrgType", IsOneOf = new string[] { "OrgType1", "OrgType2" } } }, Next = new List <Next> { new Next { Action = "NextPage", ReturnId = "12", Conditions = new List <Condition>() }, actionWithNoCondition, new Next { Action = "NextPage", ReturnId = "14", Conditions = new List <Condition>() } } }, new Page { PageId = "3", NotRequiredConditions = null } } } }; var applicationData = JObject.Parse(ApplicationDataJson); var nextActionAfterFindingNextAction = SetAnswersBase.FindNextRequiredAction(section, NextAction, applicationData); nextActionAfterFindingNextAction.Should().BeEquivalentTo(actionWithNoCondition); }
public async Task GetSectionAndPage(Guid applicationId, Guid sectionId, string pageId) { Application = await _dataContext.Applications.SingleOrDefaultAsync(app => app.Id == applicationId); Section = await _dataContext.ApplicationSections.SingleOrDefaultAsync(sec => sec.Id == sectionId && sec.ApplicationId == applicationId); if (Section != null) { QnaData = new QnAData(Section.QnAData); Page = QnaData.Pages.SingleOrDefault(p => p.PageId == pageId); } }
public void TestSetup() { _mediator = new Mock <IMediator>(); _qnaApiClient = new Mock <IInternalQnaApiClient>(); _assessorSequenceService = new Mock <IAssessorSequenceService>(); _assessorLookupService = new AssessorLookupService(); _assessorPageService = new AssessorPageService(_mediator.Object, _qnaApiClient.Object, _assessorSequenceService.Object, _assessorLookupService); _mediator.Setup(x => x.Send(It.Is <GetBlindAssessmentOutcomeRequest>(r => r.ApplicationId == _applicationId && r.SequenceNumber == _sequenceNumber && r.SectionNumber == _sectionNumber), It.IsAny <CancellationToken>())).ReturnsAsync(new BlindAssessmentOutcome()); _assessorSequenceService.Setup(x => x.IsValidSequenceNumber(It.IsAny <int>())).Returns(true); var finanicialSection = new ApplicationSection { ApplicationId = _applicationId, SequenceId = RoatpWorkflowSequenceIds.FinancialEvidence, SectionId = RoatpWorkflowSectionIds.FinancialEvidence.YourOrganisationsFinancialEvidence, QnAData = new QnAData { Pages = new List <Page> { GenerateFinanicialQnAPage() } } }; _qnaApiClient.Setup(x => x.GetSectionBySectionNo(finanicialSection.ApplicationId, finanicialSection.SequenceId, finanicialSection.SectionId)).ReturnsAsync(finanicialSection); var section = new ApplicationSection { ApplicationId = _applicationId, SequenceId = _sequenceNumber, SectionId = _sectionNumber, QnAData = new QnAData { Pages = new List <Page> { GenerateQnAPage(_firstPageId), GenerateQnAPage(_middlePageId), GenerateQnAPage(_lastPageId) } } }; _qnaApiClient.Setup(x => x.GetSectionBySectionNo(section.ApplicationId, section.SequenceId, section.SectionId)).ReturnsAsync(section); _qnaApiClient.Setup(x => x.SkipPageBySectionNo(section.ApplicationId, section.SequenceId, section.SectionId, _firstPageId)).ReturnsAsync(new SkipPageResponse { NextAction = NextAction.NextPage, NextActionId = _middlePageId }); _qnaApiClient.Setup(x => x.SkipPageBySectionNo(section.ApplicationId, section.SequenceId, section.SectionId, _middlePageId)).ReturnsAsync(new SkipPageResponse { NextAction = NextAction.NextPage, NextActionId = _lastPageId }); _qnaApiClient.Setup(x => x.SkipPageBySectionNo(section.ApplicationId, section.SequenceId, section.SectionId, _lastPageId)).ReturnsAsync(new SkipPageResponse { NextAction = NextAction.ReturnToSection }); }
private static string GetSectionText(int completedCount, ApplicationSection section, bool sequential) { if ((section.PagesComplete == section.PagesActive && section.PagesActive > 0)) { return(TaskListSectionStatus.Completed); } if (sequential && completedCount == 0) { return(TaskListSectionStatus.Next); } return(completedCount > 0 ? TaskListSectionStatus.InProgress : TaskListSectionStatus.Blank); }
public ApplicationSection ProcessPagesInSectionsForStatusText(ApplicationSection selectedSection) { foreach (var page in selectedSection.QnAData.Pages.Where(x => x.DisplayType == SectionDisplayType.PagesWithSections)) { var pages = new List <Page>(); GatherListOfPages(page, selectedSection.QnAData, pages); page.StatusText = pages.All(x => x.Complete) ? TaskListSectionStatus.Completed : pages.Any(x => x.Complete) ? TaskListSectionStatus.InProgress : string.Empty; } return(selectedSection); }
public async Task ShouldInjectFinancialInformationPage_when_FinancialEvidence_Section_Required_and_Question_Answered_returns_true(string pageId) { var application = new Apply { ApplicationId = _applicationId, ApplyData = new ApplyData { Sequences = new List <ApplySequence> { new ApplySequence { SequenceNo = RoatpWorkflowSequenceIds.FinancialEvidence, NotRequired = false, Sections = new List <ApplySection> { new ApplySection { SectionNo = RoatpWorkflowSectionIds.FinancialEvidence.YourOrganisationsFinancialEvidence, NotRequired = false } } } } } }; _mediator.Setup(x => x.Send(It.Is <GetApplicationRequest>(y => y.ApplicationId == _applicationId), It.IsAny <CancellationToken>())).ReturnsAsync(application); var qnaFinancialEvidenceSection = new ApplicationSection { ApplicationId = _applicationId, QnAData = new QnAData { Pages = new List <Domain.Apply.Page> { new Domain.Apply.Page { PageId = pageId, Active = true, Complete = true } } } }; _qnaApiClient.Setup(x => x.GetSectionBySectionNo(_applicationId, RoatpWorkflowSequenceIds.FinancialEvidence, RoatpWorkflowSectionIds.FinancialEvidence.YourOrganisationsFinancialEvidence)) .ReturnsAsync(qnaFinancialEvidenceSection); var shouldInjectPage = await _sequenceService.ShouldInjectFinancialInformationPage(_applicationId); Assert.That(shouldInjectPage, Is.True); }
static CPConfig() { s_applicationSection = (ApplicationSection)ConfigurationManager.GetSection("oversea/application"); s_keystoneSection = (KeystoneSection)ConfigurationManager.GetSection("oversea/keystone"); Object obj = ConfigurationManager.GetSection("oversea/ecCentral"); if (obj != null) { s_ecCentralSection = (ECCentralSection)obj; } else { s_ecCentralSection = null; } }
private async Task CopySections(Data.Entities.Application currentApplication, Data.Entities.Application newApplication, CancellationToken cancellationToken) { var sections = await _dataContext.ApplicationSections.AsNoTracking() .Where(sec => sec.ApplicationId == currentApplication.Id).ToListAsync(cancellationToken: cancellationToken); var newApplicationSequences = await _dataContext.ApplicationSequences.AsNoTracking() .Where(seq => seq.ApplicationId == newApplication.Id).ToListAsync(cancellationToken); var newApplicationSections = new List <ApplicationSection>(); foreach (var sequence in newApplicationSequences) { // Copy over all sections into the new Application Sequence foreach (var section in sections.Where(sec => sec.SequenceNo == sequence.SequenceNo)) { var newSection = new ApplicationSection { Id = Guid.NewGuid(), SequenceId = sequence.Id, Title = section.Title, LinkTitle = section.LinkTitle, ApplicationId = newApplication.Id, DisplayType = section.DisplayType, QnAData = section.QnAData, SectionNo = section.SectionNo, SequenceNo = section.SequenceNo }; // Adjust page info appropriately foreach (var page in newSection.QnAData.Pages) { page.SectionId = newSection.Id; page.SequenceId = newSection.SequenceId; } newApplicationSections.Add(newSection); } } await _dataContext.ApplicationSections.AddRangeAsync(newApplicationSections, cancellationToken); await _dataContext.SaveChangesAsync(cancellationToken); _logger.LogInformation($"Created ApplicationSection entities for Application: {newApplication.Id}"); }
public void AddApplicationSectionTest() { var newItem = new ApplicationSection { ApplicationTypeId = 3, ApplicationVersionId = Guid.Parse("09739F9A-76AD-4CD3-B1B0-E77DE3F628C2"), PartNumber = 999, Name = "New", Order = "999", CreatedBy = "test", CreatedDate = DateTime.Now }; this.repository.Add(newItem); var row = this.repository.GetById(newItem.Id); Assert.IsNotNull(row); }
public void Then_the_page_is_marked_as_not_required() { var section = new ApplicationSection { ApplicationId = ApplicationId, QnAData = new QnAData { Pages = new List <Page> { new Page { PageId = "2", NotRequiredConditions = new List <NotRequiredCondition> { new NotRequiredCondition() { Field = "OrgType", IsOneOf = new string[] { "OrgType1", "OrgType2" } } }, Next = new List <Next> { new Next { Action = "NextPage", ReturnId = "12", Conditions = new List <Condition>() } } }, new Page { PageId = "3", NotRequiredConditions = null } } } }; var applicationData = JObject.Parse(ApplicationDataJson); SetAnswersBase.FindNextRequiredAction(section, NextAction, applicationData); Assert.IsTrue(section.QnAData.Pages.First().NotRequired); }
public async Task For_empty_NotRequiredConditions_then_the_same_nextAction_is_returned() { var section = new ApplicationSection { ApplicationId = ApplicationId, QnAData = new QnAData { Pages = new List <Page> { new Page { PageId = "2", NotRequiredConditions = new List <NotRequiredCondition>() } } } }; var applicationData = JObject.Parse(ApplicationDataJson); var nextActionAfterFindingNextAction = SetAnswersBase.FindNextRequiredAction(section, NextAction, applicationData); nextActionAfterFindingNextAction.Should().BeEquivalentTo(NextAction); }
public ApplicationSectionViewModel(Guid applicationId, int sequenceId, int sectionId, ApplicationSection section, AssessorService.ApplyTypes.Application application) { if (section != null) { Section = section; Title = section.Title; ApplicationId = section.ApplicationId; SequenceId = section.SequenceId; SectionId = section.SectionId; if (section.Status == ApplicationSectionStatus.Evaluated) { IsSectionComplete = true; } } else { ApplicationId = applicationId; SequenceId = sequenceId; SectionId = sectionId; } if (application != null) { if (application.ApplicationData != null) { ApplicationReference = application.ApplicationData.ReferenceNumber; } if (application.ApplyingOrganisation?.OrganisationData != null) { Ukprn = application.ApplyingOrganisation.EndPointAssessorUkprn; LegalName = application.ApplyingOrganisation.OrganisationData.LegalName; TradingName = application.ApplyingOrganisation.OrganisationData.TradingName; ProviderName = application.ApplyingOrganisation.OrganisationData.ProviderName; CompanyNumber = application.ApplyingOrganisation.OrganisationData.CompanyNumber; } } }
public async Task SetUp() { _dataContext = DataContextHelpers.GetInMemoryDataContext(); _applicationId = Guid.NewGuid(); _sectionId = Guid.NewGuid(); _feedbackId = Guid.NewGuid(); var section = new ApplicationSection { ApplicationId = _applicationId, Id = _sectionId, QnAData = new QnAData { Pages = new List <Page> { new Page { PageId = "1", Feedback = new List <Feedback> { new Feedback { Id = _feedbackId } } } } } }; await _dataContext.ApplicationSections.AddAsync(section); await _dataContext.SaveChangesAsync(); _handler = new UpsertFeedbackHandler(_dataContext); }
protected void SaveAnswersIntoPage(ApplicationSection section, string pageId, List <Answer> submittedAnswers) { if (section != null) { // Have to force QnAData a new object and reassign for Entity Framework to pick up changes var qnaData = new QnAData(section.QnAData); var page = qnaData?.Pages.SingleOrDefault(p => p.PageId == pageId); if (page != null) { var answers = GetAnswersFromRequest(submittedAnswers); page.PageOfAnswers = new List <PageOfAnswers>(new[] { new PageOfAnswers() { Answers = answers } }); MarkPageAsComplete(page); MarkPageFeedbackAsComplete(page); // Assign QnAData back so Entity Framework will pick up changes section.QnAData = qnaData; } } }
private bool ApplicationInit() { Logger.Trace("=== Application loader start ==="); var config = ApplicationSection.Get(); RestartInterval = new TimeSpan(config.Timer / 60, config.Timer % 60, 0); Logger.Debug("Restart interval is set on {0} minutes", RestartInterval.TotalMinutes); Emails = config.Email.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (Directory.Exists(config.Path)) { ExtensionPath = new Uri(config.Path); Logger.Debug("Extension path found on {0}", ExtensionPath.AbsolutePath); } else { ExtensionPath = new Uri(Directory.GetCurrentDirectory()); Logger.Error("Extension path not found on {0}", config.Path); return(false); } Logger.Debug("=== Application loader end ==="); return(true); }
public void Before_each_test() { _sessionService = new Mock <ISessionService>(); _qnaApiClient = new Mock <IQnaApiClient>(); _section = new ApplicationSection { Id = Guid.NewGuid(), SectionId = SectionId }; _section.QnAData = new QnAData { Pages = new List <Page> { new Page { PageId = "100" }, new Page { PageId = "110" } } }; _qnaApiClient.Setup(x => x.GetSectionBySectionNo(It.IsAny <Guid>(), SequenceId, SectionId)).ReturnsAsync(_section); _service = new PageNavigationTrackingService(_sessionService.Object, _qnaApiClient.Object); }
public void NavigateTo(ApplicationSection section) { }