/// <summary> /// /// </summary> /// <param name="f1Emails"></param> /// <param name="pcoEmails"></param> private void UpdateEmailCommunications(F1toPCO.Model.F1.communications f1Emails, F1toPCO.Model.PCO.emailAddresses pcoEmails) { foreach (F1toPCO.Model.F1.EntityType et in F1toPCO.Model.F1.emailSyncType.Items) { F1toPCO.Model.F1.communication tmpF1Email = f1Emails.FindByCommunicationTypeName(et.F1Type); F1toPCO.Model.PCO.emailAddress tmpPCOEmail = pcoEmails.FindByLocation(et.PCOType); if (tmpF1Email != null) { if (tmpPCOEmail == null) { tmpPCOEmail = new Model.PCO.emailAddress(); tmpPCOEmail.address = tmpF1Email.communicationValue; tmpPCOEmail.location = et.PCOType; pcoEmails.emailAddress.Add(tmpPCOEmail); } else { tmpPCOEmail.address = tmpF1Email.communicationValue; } } else { if (tmpPCOEmail != null) { pcoEmails.emailAddress.Remove(tmpPCOEmail); } } } }
/// <summary> /// /// </summary> /// <param name="f1Phones"></param> /// <param name="pcoPhones"></param> private void UpdatePhoneCommunications(F1toPCO.Model.F1.communications f1Phones, F1toPCO.Model.PCO.phoneNumbers pcoPhones) { foreach (F1toPCO.Model.F1.EntityType et in F1toPCO.Model.F1.phoneSyncType.Items) { F1toPCO.Model.F1.communication tmpF1Phone = f1Phones.FindByCommunicationTypeName(et.F1Type); F1toPCO.Model.PCO.phoneNumber tmpPCOPhone = pcoPhones.FindByLocation(et.PCOType); if (tmpF1Phone != null) { if (tmpPCOPhone == null) { tmpPCOPhone = new Model.PCO.phoneNumber(); tmpPCOPhone.number = tmpF1Phone.communicationValue; tmpPCOPhone.location = et.PCOType; pcoPhones.phoneNumber.Add(tmpPCOPhone); } else { tmpPCOPhone.number = tmpF1Phone.communicationValue; } } else { if (tmpPCOPhone != null) { pcoPhones.phoneNumber.Remove(tmpPCOPhone); } } } }
/// <summary> /// /// </summary> /// <param name="f1Person"></param> /// <param name="pcoPerson"></param> private void UpdatePerson(F1toPCO.Model.F1.person f1Person, ref F1toPCO.Model.PCO.person pcoPerson) { pcoPerson.firstname = string.IsNullOrEmpty(f1Person.goesByName) ? f1Person.firstName : f1Person.goesByName; pcoPerson.lastname = f1Person.lastName; //Emails F1toPCO.Model.F1.communications emailComms = new F1toPCO.Model.F1.communications(); emailComms.items = f1Person.communications.FindByGeneralCommunicationType(F1toPCO.Model.F1.communicationGeneralType.Email); UpdateEmailCommunications(emailComms, pcoPerson.contactData.emailAddresses); //Phone numbers F1toPCO.Model.F1.communications phoneComs = new F1toPCO.Model.F1.communications(); phoneComs.items = f1Person.communications.FindByGeneralCommunicationType(F1toPCO.Model.F1.communicationGeneralType.Telephone); UpdatePhoneCommunications(phoneComs, pcoPerson.contactData.phoneNumbers); //Address F1toPCO.Model.F1.address primaryAddress = f1Person.addresses.FindByType("Primary"); F1toPCO.Model.PCO.address pcoAddress = pcoPerson.contactData.addresses.FindByLocation("Home"); if (primaryAddress != null) { if (pcoAddress == null) { pcoAddress = new F1toPCO.Model.PCO.address(); pcoPerson.contactData.addresses.address.Add(pcoAddress); } pcoAddress.street = FormatStreet(primaryAddress); pcoAddress.city = primaryAddress.city; pcoAddress.state = primaryAddress.stProvince; pcoAddress.zip = primaryAddress.postalCode; } else { if (pcoAddress != null) { pcoPerson.contactData.addresses.address.Remove(pcoAddress); } } }