private ResidentInformation MapDetailsToResidentInformation(Person person, Address address, TenancyAgreement tenancyAgreement, ContactLink contactLink, int?contactKey) { var resident = person.ToDomain(); resident.UPRN = address?.UPRN; resident.ResidentAddress = address?.ToDomain(); resident.TenancyReference = tenancyAgreement?.TagRef.Trim(); resident.ContactKey = contactKey.ToString(); resident.TenureType = (tenancyAgreement == null) ? null : $"{tenancyAgreement.UhTenureTypeId.Trim()}: {tenancyAgreement.UhTenureType.Description.Trim()}"; if (contactLink == null) { return(resident); } var telephoneNumberForPerson = _UHContext .TelephoneNumbers.Where(t => t.ContactID == contactLink.ContactID).ToList(); var emailAddressForPerson = _UHContext.EmailAddresses.Where(c => c.ContactID == contactLink.ContactID).ToList(); AttachContactDetailsToPerson(resident, telephoneNumberForPerson, emailAddressForPerson); return(resident); }
private static ResidentInformation MapToExpectedDomain(Person databaseEntity, Address address, List <Phone> phoneNumber, List <Email> emailAddresses, TenancyAgreement tenancy, string contactKey = "") { var domainEntity = databaseEntity.ToDomain(); domainEntity.ResidentAddress = address.ToDomain(); domainEntity.UPRN = address.UPRN; domainEntity.PhoneNumber = phoneNumber; domainEntity.Email = emailAddresses; domainEntity.TenancyReference = tenancy.TagRef; domainEntity.ContactKey = contactKey; domainEntity.TenureType = (tenancy == null) ? null : $"{tenancy.UhTenureTypeId.Trim()}: {tenancy.UhTenureType.Description.Trim()}"; return(domainEntity); }