private static bool AddPhoneUpdates(this FWTIndividualUpdate update, FWTIndividual individual, Customer customer) { if (individual.RequiresPhoneUpdate(customer)) { var newPhone = new FWTContactPhone { Number = customer.Telephone, Preferred = true, DeviceType = "unknown" }; update.ContactPhones = new[] { new FWTContactPhoneUpdate { PhoneDetails = newPhone, ListItemUpdateType = "Insert" } }; return(true); } if ((!string.IsNullOrWhiteSpace(customer.Telephone) && individual.ContactPhones != null) && (individual.ContactPhones.Where(x => x.Number.Replace(" ", "").Replace("-", "").Equals(customer.Telephone.Replace(" ", "").Replace("-", "")) && x.Preferred == false).Count() > 0)) { var updatePhone = individual.ContactPhones.FirstOrDefault(x => x.Number.Replace(" ", "").Replace("-", "").Equals(customer.Telephone.Replace(" ", "").Replace("-", ""))); if (updatePhone != null) { updatePhone.Preferred = true; update.ContactPhones = new[] { new FWTContactPhoneUpdate { PhoneDetails = updatePhone, ListItemUpdateType = "Update" } }; return(true); } } return(false); }
public static FWTIndividual Map(this Customer customer) { var contactName = new FWTIndividualName { Title = customer.Title?.Trim(), Forename = new[] { customer.Forename?.Trim() }, Initials = customer.Initials?.Trim(), Surname = customer.Surname?.Trim(), Preferred = true }; var personDetails = new FWTIndividual { Name = new[] { contactName } }; if (customer.DateOfBirth != DateTime.MinValue) { personDetails.DateOfBirth = customer.DateOfBirth; personDetails.DateOfBirthSpecified = true; } // Setup the address details if (customer.Address != null) { personDetails.ContactPostals = new[] { (customer.Address.Map()) }; } // Setup the telephone contact information. var contactPhones = new FWTContactPhone { Number = customer.Telephone?.Trim(), Preferred = true }; personDetails.ContactPhones = new[] { contactPhones }; // Setup email address information. var contactEmails = new FWTContactEmail { EmailAddress = customer.Email?.Trim(), Preferred = true }; personDetails.ContactEmails = new[] { contactEmails }; return(personDetails); }