public async Task <string> Handle(SubmitAnonymousEvacuationFileCommand cmd) { var file = mapper.Map <Resources.Cases.Evacuations.EvacuationFile>(cmd.File); var contact = mapper.Map <Contact>(cmd.SubmitterProfile); file.PrimaryRegistrantId = (await contactRepository.ManageContact(new SaveContact { Contact = contact })).ContactId; file.NeedsAssessment.HouseholdMembers.Where(m => m.IsPrimaryRegistrant).Single().LinkedRegistrantId = file.PrimaryRegistrantId; var caseId = (await caseRepository.ManageCase(new SubmitEvacuationFileNeedsAssessment { EvacuationFile = file })).Id; if (contact.Email != null) { await SendEmailNotification( SubmissionTemplateType.NewAnonymousEvacuationFileSubmission, email : contact.Email, name : $"{contact.LastName}, {contact.FirstName}", tokens : new[] { KeyValuePair.Create("fileNumber", caseId) }); } return(caseId); }
public async Task CanSubmitAnonymousRegistration() { var textContextIdentifier = DateTime.Now.ToShortTimeString(); List <SecurityQuestion> securityQuestions = new List <SecurityQuestion>(); securityQuestions.Add(new SecurityQuestion { Id = 1, Question = "question1", Answer = "answer1" }); securityQuestions.Add(new SecurityQuestion { Id = 2, Question = "question2", Answer = "answer2" }); securityQuestions.Add(new SecurityQuestion { Id = 3, Question = "question3", Answer = "answer3" }); var profile = new RegistrantProfile { UserId = null, Id = null, AuthenticatedUser = false, VerifiedUser = false, RestrictedAccess = false, SecurityQuestions = securityQuestions, FirstName = $"PriRegTestFirst-{textContextIdentifier}", LastName = $"PriRegTestLast-{textContextIdentifier}", DateOfBirth = "2000/01/01", Gender = "Female", Initials = "initials1", PreferredName = "preferred1", Email = "*****@*****.**", Phone = "999-999-9999", PrimaryAddress = new Address { AddressLine1 = $"paddr1-{textContextIdentifier}", AddressLine2 = "paddr2", Country = "CAN", StateProvince = "BC", PostalCode = "v1v 1v1", Community = "226adfaf-9f97-ea11-b813-005056830319" }, MailingAddress = new Address { AddressLine1 = $"maddr1-{textContextIdentifier}", AddressLine2 = "maddr2", Country = "USA", StateProvince = "WA", PostalCode = "12345", Community = "Seattle" } }; var needsAssessment = new NeedsAssessment { HouseholdMembers = new[] { new HouseholdMember { Id = null, FirstName = $"MemRegTestFirst-{textContextIdentifier}", LastName = $"MemRegTestLast-{textContextIdentifier}", Gender = "X", DateOfBirth = "2010-01-01" } }, HaveMedication = false, Insurance = InsuranceOption.Yes, HaveSpecialDiet = true, SpecialDietDetails = "Gluten Free", HasPetsFood = true, CanEvacueeProvideClothing = false, CanEvacueeProvideFood = true, CanEvacueeProvideIncidentals = null, CanEvacueeProvideLodging = false, CanEvacueeProvideTransportation = true, Pets = new[] { new Pet { Type = $"dog{textContextIdentifier}", Quantity = "4" } } }; var cmd = new SubmitAnonymousEvacuationFileCommand { File = new EvacuationFile { EvacuatedFromAddress = new Address { AddressLine1 = $"addr1-{textContextIdentifier}", Country = "CAN", Community = "226adfaf-9f97-ea11-b813-005056830319", StateProvince = "BC", PostalCode = "v1v 1v1" }, EvacuationDate = DateTime.Now, NeedsAssessments = new[] { needsAssessment }, }, SubmitterProfile = profile }; var fileId = await manager.Handle(cmd); fileId.ShouldNotBeNull(); }
public async Task CanSubmitAnonymousRegistration() { var textContextIdentifier = Guid.NewGuid().ToString().Substring(0, 4); var securityQuestions = new List <SecurityQuestion>(); securityQuestions.Add(new SecurityQuestion { Id = 1, Question = "question1", Answer = "answer1" }); securityQuestions.Add(new SecurityQuestion { Id = 2, Question = "question2", Answer = "answer2" }); securityQuestions.Add(new SecurityQuestion { Id = 3, Question = "question3", Answer = "answer3" }); var profile = new RegistrantProfile { UserId = null, Id = null, AuthenticatedUser = false, VerifiedUser = false, RestrictedAccess = false, SecurityQuestions = securityQuestions, FirstName = $"{textContextIdentifier}-PriRegTestFirst", LastName = $"{textContextIdentifier}-PriRegTestLast", DateOfBirth = "2000/01/01", Gender = "Female", Initials = "initials1", PreferredName = "preferred1", Email = "*****@*****.**", Phone = "999-999-9999", PrimaryAddress = new Address { AddressLine1 = $"paddr1", AddressLine2 = "paddr2", Country = "CAN", StateProvince = "BC", PostalCode = "v1v 1v1", Community = TestData.RandomCommunity }, MailingAddress = new Address { AddressLine1 = $"maddr1", AddressLine2 = "maddr2", Country = "USA", StateProvince = "WA", PostalCode = "12345", Community = "Seattle" } }; var needsAssessment = new NeedsAssessment { HouseholdMembers = new[] { new HouseholdMember { IsPrimaryRegistrant = true, FirstName = profile.FirstName, LastName = profile.LastName, DateOfBirth = profile.DateOfBirth, Gender = profile.Gender, Initials = profile.Initials, }, new HouseholdMember { IsPrimaryRegistrant = false, Id = null, FirstName = $"{textContextIdentifier}-MemRegTestFirst", LastName = $"{textContextIdentifier}-MemRegTestLast", Gender = "X", DateOfBirth = "2010-01-01" } }, TakeMedication = false, HaveMedicalSupplies = false, Insurance = InsuranceOption.Yes, HaveSpecialDiet = true, SpecialDietDetails = "Gluten Free", HavePetsFood = true, CanProvideClothing = false, CanProvideFood = true, CanProvideIncidentals = null, CanProvideLodging = false, CanProvideTransportation = true, Pets = new[] { new Pet { Type = $"dog{textContextIdentifier}", Quantity = "4" } } }; var cmd = new SubmitAnonymousEvacuationFileCommand { File = new EvacuationFile { EvacuatedFromAddress = new Address { AddressLine1 = $"addr1", Country = "CAN", Community = TestData.RandomCommunity, StateProvince = "BC", PostalCode = "v1v 1v1" }, NeedsAssessment = needsAssessment, }, SubmitterProfile = profile }; var fileId = (await manager.Handle(cmd)).ShouldNotBeNull(); var file = (await manager.Handle(new EvacuationFilesQuery { FileId = fileId })).Items.ShouldHaveSingleItem(); file.HouseholdMembers.ShouldContain(m => m.IsPrimaryRegistrant == true && m.FirstName == profile.FirstName && m.LastName == profile.LastName); file.NeedsAssessment.HouseholdMembers.ShouldContain(m => m.IsPrimaryRegistrant == true && m.FirstName == profile.FirstName && m.LastName == profile.LastName); file.NeedsAssessment.HouseholdMembers.ShouldContain(m => m.IsPrimaryRegistrant == false && m.FirstName == $"{textContextIdentifier}-MemRegTestFirst" && m.LastName == $"{textContextIdentifier}-MemRegTestLast"); }