public void Setup() { _existingDbPerson = IntegrationTestHelpers.CreateExistingPerson(DatabaseContext); _mashReferral = IntegrationTestHelpers.SaveMashReferralToDatabase(DatabaseContext, "CONTACT"); _unlinkedResident = IntegrationTestHelpers.CreateMashResident(DatabaseContext, _mashReferral, _existingDbPerson); }
public MashReferral CreateReferral(CreateReferralRequest request) { var referral = new Infrastructure.MashReferral { Referrer = request.Referrer, RequestedSupport = request.RequestedSupport, ReferralDocumentURI = request.ReferralUri, Stage = "CONTACT", ReferralCreatedAt = _systemTime.Now, MashResidents = new List <MashResident>(), CreatedBy = request.Referrer, LastModifiedBy = request.Referrer }; foreach (var mashResident in request.MashResidents) { var resident = new MashResident { FirstName = mashResident.FirstName, LastName = mashResident.LastName, Address = mashResident.Address, Ethnicity = mashResident.Ethnicity, Gender = mashResident.Gender, Postcode = mashResident.Postcode, School = mashResident.School, FirstLanguage = mashResident.FirstLanguage, DateOfBirth = mashResident.DateOfBirth, MashReferralId = referral.Id }; referral.MashResidents.Add(resident); } _databaseContext.MashReferrals.Add(referral); _databaseContext.SaveChanges(); return(referral.ToDomain()); }