private Contact CopyContact(Contact contact)
        {
            List <ContactIdentifier> identifiers = contact.Identifiers.Select(
                identifier => identifier.Source != "Alias"
                                  ? identifier
                                  : new ContactIdentifier(
                    "AliasOld",
                    identifier.Identifier,
                    ContactIdentifierType.Anonymous)).ToList();
            Contact result = new Contact(identifiers.ToArray());

            _client.AddContact(result);

            // Default Facets
            if (contact.Facets.ContainsKey(PersonalInformation.DefaultFacetKey))
            {
                _client.SetFacet(
                    result,
                    PersonalInformation.DefaultFacetKey,
                    contact.GetFacet <PersonalInformation>().WithClearedConcurrency());
            }

            if (contact.Facets.ContainsKey(EmailAddressList.DefaultFacetKey))
            {
                _client.SetFacet(
                    result,
                    EmailAddressList.DefaultFacetKey,
                    contact.GetFacet <EmailAddressList>().WithClearedConcurrency());
            }

            if (contact.Facets.ContainsKey(AddressList.DefaultFacetKey))
            {
                _client.SetAddresses(result, contact.Addresses().WithClearedConcurrency());
            }

            if (contact.Facets.ContainsKey(PhoneNumberList.DefaultFacetKey))
            {
                _client.SetPhoneNumbers(result, contact.PhoneNumbers().WithClearedConcurrency());
            }

            if (contact.Facets.ContainsKey(ConsentInformation.DefaultFacetKey))
            {
                _client.SetConsentInformation(result, contact.ConsentInformation().WithClearedConcurrency());
            }

            if (contact.Facets.ContainsKey(ListSubscriptions.DefaultFacetKey))
            {
                _client.SetListSubscriptions(result, contact.ListSubscriptions().WithClearedConcurrency());
            }

            if (contact.Facets.ContainsKey(Avatar.DefaultFacetKey))
            {
                _client.SetAvatar(result, contact.Avatar().WithClearedConcurrency());
            }

            if (contact.Facets.ContainsKey(EmailAddressHistory.DefaultFacetKey))
            {
                _client.SetFacet(
                    result,
                    EmailAddressHistory.DefaultFacetKey,
                    contact.GetFacet <EmailAddressHistory>().WithClearedConcurrency());
            }

            if (contact.Facets.ContainsKey("TestCombinations"))
            {
                Facet oldFacet = contact.Facets["TestCombinations"];
                TestCombinationsData newFacet = new TestCombinationsData();
                newFacet.TestCombinations = oldFacet.XObject["TestCombinations"]?.ToString();
                _client.SetFacet(result, "TestCombinations", newFacet);
            }

            // TODO Handle custom facets

            _client.Submit();

            return(result);
        }
        private void SetContact(Contact target, Contact source)
        {
            // Default Facets
            if (source.Facets.ContainsKey(PersonalInformation.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(PersonalInformation.DefaultFacetKey))
                {
                    PersonalInformation sourceFacet = source.GetFacet <PersonalInformation>();
                    PersonalInformation targetFacet = target.GetFacet <PersonalInformation>();
                    targetFacet.Birthdate         = sourceFacet.Birthdate;
                    targetFacet.FirstName         = sourceFacet.FirstName;
                    targetFacet.Gender            = sourceFacet.Gender;
                    targetFacet.JobTitle          = sourceFacet.JobTitle;
                    targetFacet.Title             = sourceFacet.Title;
                    targetFacet.LastName          = sourceFacet.LastName;
                    targetFacet.MiddleName        = sourceFacet.MiddleName;
                    targetFacet.Nickname          = sourceFacet.Nickname;
                    targetFacet.PreferredLanguage = sourceFacet.PreferredLanguage;
                    targetFacet.Suffix            = sourceFacet.Suffix;
                    _client.SetFacet(target, PersonalInformation.DefaultFacetKey, targetFacet);
                }
                else
                {
                    _client.SetFacet(
                        target,
                        PersonalInformation.DefaultFacetKey,
                        source.GetFacet <PersonalInformation>().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey(EmailAddressList.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(EmailAddressList.DefaultFacetKey))
                {
                    EmailAddressList sourceFacet = source.GetFacet <EmailAddressList>();
                    EmailAddressList targetFacet = target.GetFacet <EmailAddressList>();
                    targetFacet.Others         = sourceFacet.Others;
                    targetFacet.PreferredEmail = sourceFacet.PreferredEmail;
                    targetFacet.PreferredKey   = sourceFacet.PreferredKey;
                    _client.SetFacet(target, EmailAddressList.DefaultFacetKey, targetFacet);
                }
                else
                {
                    _client.SetFacet(
                        target,
                        EmailAddressList.DefaultFacetKey,
                        source.GetFacet <EmailAddressList>().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey(AddressList.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(AddressList.DefaultFacetKey))
                {
                    AddressList sourceFacet = source.Addresses();
                    AddressList targetFacet = target.Addresses();
                    targetFacet.PreferredKey     = sourceFacet.PreferredKey;
                    targetFacet.Others           = sourceFacet.Others;
                    targetFacet.PreferredAddress = sourceFacet.PreferredAddress;
                    _client.SetAddresses(target, targetFacet);
                }
                else
                {
                    _client.SetAddresses(target, source.Addresses().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey(PhoneNumberList.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(PhoneNumberList.DefaultFacetKey))
                {
                    PhoneNumberList sourceFacet = source.PhoneNumbers();
                    PhoneNumberList targetFacet = target.PhoneNumbers();
                    targetFacet.PreferredKey         = sourceFacet.PreferredKey;
                    targetFacet.Others               = sourceFacet.Others;
                    targetFacet.PreferredPhoneNumber = sourceFacet.PreferredPhoneNumber;
                    _client.SetPhoneNumbers(target, targetFacet);
                }
                else
                {
                    _client.SetPhoneNumbers(target, source.PhoneNumbers().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey(ConsentInformation.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(ConsentInformation.DefaultFacetKey))
                {
                    ConsentInformation sourceFacet = source.ConsentInformation();
                    ConsentInformation targetFacet = target.ConsentInformation();
                    targetFacet.ConsentRevoked             = sourceFacet.ConsentRevoked;
                    targetFacet.DoNotMarket                = sourceFacet.DoNotMarket;
                    targetFacet.ExecutedRightToBeForgotten = sourceFacet.ExecutedRightToBeForgotten;
                    _client.SetConsentInformation(target, targetFacet);
                }
                else
                {
                    _client.SetConsentInformation(target, source.ConsentInformation().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey(ListSubscriptions.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(ListSubscriptions.DefaultFacetKey))
                {
                    ListSubscriptions sourceFacet = source.ListSubscriptions();
                    ListSubscriptions targetFacet = target.ListSubscriptions();
                    targetFacet.Subscriptions = sourceFacet.Subscriptions;
                    _client.SetListSubscriptions(target, targetFacet);
                }
                else
                {
                    _client.SetListSubscriptions(target, source.ListSubscriptions().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey(Avatar.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(Avatar.DefaultFacetKey))
                {
                    Avatar sourceFacet = source.Avatar();
                    Avatar targetFacet = target.Avatar();
                    targetFacet.MimeType = sourceFacet.MimeType;
                    targetFacet.Picture  = sourceFacet.Picture;
                    _client.SetAvatar(target, targetFacet);
                }
                else
                {
                    _client.SetAvatar(target, source.Avatar().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey(EmailAddressHistory.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(EmailAddressHistory.DefaultFacetKey))
                {
                    EmailAddressHistory sourceFacet = source.GetFacet <EmailAddressHistory>();
                    EmailAddressHistory targetFacet = target.GetFacet <EmailAddressHistory>();
                    targetFacet.History = sourceFacet.History;
                    _client.SetFacet(target, EmailAddressHistory.DefaultFacetKey, targetFacet);
                }
                else
                {
                    _client.SetFacet(
                        target,
                        EmailAddressHistory.DefaultFacetKey,
                        source.GetFacet <EmailAddressHistory>().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey("TestCombinations"))
            {
                if (target.Facets.ContainsKey("TestCombinations"))
                {
                    TestCombinationsData sourceFacet = source.Facets["TestCombinations"] as TestCombinationsData;
                    if (target.Facets["TestCombinations"] is TestCombinationsData targetFacet)
                    {
                        targetFacet.TestCombinations = sourceFacet?.TestCombinations;
                        _client.SetFacet(target, "TestCombinations", targetFacet);
                    }
                }
                else
                {
                    Facet oldFacet = source.Facets["TestCombinations"];
                    TestCombinationsData newFacet = new TestCombinationsData();
                    newFacet.TestCombinations = oldFacet.XObject["TestCombinations"]?.ToString();
                    _client.SetFacet(target, "TestCombinations", newFacet);
                }
            }

            // TODO Handle custom facets

            _client.Submit();
        }