public void Find_OnlyReturnLatest() { var userId = "*****@*****.**"; var existingForm1 = new BestStartGrantBuilder("form1").WithCompletedSections().With(f => f.UserId, userId).With(f => f.Completed, new DateTime(2008, 07, 06)).Insert(); var existingForm2 = new BestStartGrantBuilder("form2").WithCompletedSections().With(f => f.UserId, userId).With(f => f.Completed, new DateTime(2009, 07, 06)).Insert(); var existingForm3 = new BestStartGrantBuilder("form3").WithCompletedSections().With(f => f.UserId, userId).With(f => f.Completed, new DateTime(2007, 07, 06)).Insert(); var query = new FindLatestApplication { UserId = userId, }; var detail = query.Find(); detail.Should().NotBeNull(); detail.Id.Should().Be(existingForm2.Id); }
public NextSection AddIdentity(string userId) { ValidateIdentity(userId); var existingForm = new FindLatestApplication { UserId = userId }.Find(); if (existingForm == null) { throw new DomainException("Could not find any existing application for the supplied email"); } UserId = userId; var fullName = new StringBuilder(); fullName.Append(existingForm.ApplicantDetails.FirstName); if (!string.IsNullOrEmpty(existingForm.ApplicantDetails.OtherNames)) { fullName.AppendFormat(" {0}", existingForm.ApplicantDetails.OtherNames); } fullName.AppendFormat(" {0}", existingForm.ApplicantDetails.SurnameOrFamilyName); ExistingApplicantDetails = new ApplicantDetails { Title = existingForm.ApplicantDetails.Title, FullName = fullName.ToString(), Address = existingForm.ApplicantDetails.CurrentAddress, MobilePhoneNumber = existingForm.ApplicantDetails.MobilePhoneNumber, HomePhoneNumer = existingForm.ApplicantDetails.PhoneNumer, EmailAddress = existingForm.ApplicantDetails.EmailAddress, Age = existingForm.ApplicantDetails.Age(), }; ExistingPaymentDetails = new PaymentDetails { HasBankAccount = existingForm.PaymentDetails.HasBankAccount, }; return(OnSectionCompleted(Sections.Identity)); }
public void Find_OnlyReturnsCompleted() { var userId = "*****@*****.**"; var existingForm1 = new BestStartGrantBuilder("form1") .WithCompletedSections(markAsCompleted: false) .With(f => f.UserId, userId) .With(f => f.Declaration, null) .Insert(); var query = new FindLatestApplication { UserId = userId, }; var detail = query.Find(); detail.Should().BeNull(); }