/// <summary> /// Sets the <see cref="EmailAddressList"/> facet of the specified <paramref name="contact" />. /// </summary> /// <param name="email">The email address.</param> /// <param name="contact">The contact.</param> /// <param name="client">The client.</param> private static void SetEmail(string email, Contact contact, IXdbContext client) { if (string.IsNullOrEmpty(email)) { return; } EmailAddressList emailFacet = contact.Emails(); if (emailFacet == null) { emailFacet = new EmailAddressList(new EmailAddress(email, false), "Preferred"); } else { if (emailFacet.PreferredEmail?.SmtpAddress == email) { return; } emailFacet.PreferredEmail = new EmailAddress(email, false); } client.SetEmails(contact, emailFacet); }
private static void SetEmail(Sitecore.XConnect.Contact contact, IXConnectContactWithEmail xConnectContact, IXdbContext client) { if (string.IsNullOrEmpty(xConnectContact.Email)) { return; } var facet = contact.Emails(); if (facet == null) { facet = new EmailAddressList(new EmailAddress(xConnectContact.Email, false), "Preferred"); } else { if (facet.PreferredEmail?.SmtpAddress == xConnectContact.IdentifierValue) { return; } facet.PreferredEmail = new EmailAddress(xConnectContact.Email, false); } client.SetEmails(contact, facet); }
private static void AddPreferredEmail(int i, IXdbContext client, Contact contact, string emailAddress) { client.SetEmails(contact, new EmailAddressList(new EmailAddress(emailAddress, false), "Preferred")); }