Skip to content

Instantly share code, notes, and snippets.

@hishaamn
Created May 28, 2017 16:46
Show Gist options
  • Save hishaamn/b72c5e73a4a3b08ecea0fa1849742faf to your computer and use it in GitHub Desktop.
Save hishaamn/b72c5e73a4a3b08ecea0fa1849742faf to your computer and use it in GitHub Desktop.
private void SetProfileKeys(ContentProfile profile, ProfileItem profileItem)
{
foreach (ProfileKeyItem profileKeyItem in profileItem.Keys.ToList())
{
ProfileKeyItem keyItem = profileKeyItem;
if (profile.Keys.FirstOrDefault(k => string.Compare(k.Key, keyItem.Name, StringComparison.InvariantCultureIgnoreCase) == 0) == null)
{
ContentProfileKeyData key = new ContentProfileKeyData(keyItem)
{
Value = keyItem.GetDefaultValue()
};
profile.AddKey(key);
}
}
foreach (ContentProfileKeyData key in profile.Keys.Where(key => key.ProfileDefinitionId == Guid.Empty))
{
profile.RemoveKey(key);
}
TrackingField.UpdateKeyValues(profile);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment