public static void CopySectionsFrom(ChangeOfCircs form, CocDetail detail, bool useExisting = false) { detail.Consent = form.Consent; detail.Identity = form.UserId; detail.Options = form.Options; detail.ApplicantDetails = useExisting ? form.ExistingApplicantDetails : form.ApplicantDetails; detail.ExpectedChildren = form.ExpectedChildren; detail.HealthProfessional = form.HealthProfessional; detail.PaymentDetails = useExisting ? form.ExistingPaymentDetails : form.PaymentDetails; detail.Evidence = form.Evidence; detail.Declaration = form.Declaration; }
protected static CocDetail NewCocDetail(string formId) { var detail = new CocDetail { Id = formId, Consent = ConsentBuilder.NewValid(), Identity = "*****@*****.**", Options = OptionsBuilder.NewValid(), ApplicantDetails = ApplicantDetailsBuilder.NewValid(), ExpectedChildren = ExpectedChildrenBuilder.NewValid(), HealthProfessional = HealthProfessionalBuilder.NewValid(), PaymentDetails = PaymentDetailsBuilder.NewValid(), Evidence = EvidenceBuilder.NewValid(), Declaration = DeclarationBuilder.NewValid(), }; return(detail); }
public CocDetail FindSection(Sections section) { var detail = new CocDetail { Consent = Consent, Identity = UserId, Options = Options, ApplicantDetails = ApplicantDetails ?? ExistingApplicantDetails, ExpectedChildren = ExpectedChildren, HealthProfessional = HealthProfessional, PaymentDetails = PaymentDetails ?? ExistingPaymentDetails, Evidence = Evidence, Declaration = Declaration, }; Navigation.Populate(detail, section, this); return(detail); }
public void Find_PopulatesExistingDetail_IfCurrentDetailDoesNotExist() { var existingForm = new ChangeOfCircsBuilder("form123") .WithCompletedSections(excludeOptionalSections: true) .Insert(); var query = new FindCocSection { FormId = "form123", Section = Sections.Consent, }; var details = query.Find(); var expectedDetail = new CocDetail { PreviousSection = null }; ChangeOfCircsBuilder.CopySectionsFrom(existingForm, expectedDetail, useExisting: true); details.ShouldBeEquivalentTo(expectedDetail); }
public void Find_PopulatesDetail() { var existingForm = new ChangeOfCircsBuilder("form123") .WithCompletedSections(markAsCompleted: false) .Insert(); var query = new FindCocSection { FormId = "form123", Section = Sections.Consent, }; var detail = query.Find(); var expectedDetail = new CocDetail { PreviousSection = null }; ChangeOfCircsBuilder.CopySectionsFrom(existingForm, expectedDetail); detail.ShouldBeEquivalentTo(expectedDetail); }
public static void Populate(CocDetail detail, Sections section, ChangeOfCircs form) { var index = _order.IndexOf(section) - 1; while (index >= 0 && !detail.PreviousSection.HasValue) { var previousSection = _order[index]; if (!FeatureToggles.SkipWorkInProgressSection(previousSection)) { var strategy = SectionStrategy.For(previousSection); if (strategy.Required(form)) { detail.PreviousSection = previousSection; } } index--; } detail.IsFinalSection = (section == _order.Last()); }