private void ApplyChanges(AppliedTags change, ContentItem item) { DetailCollection links = item.GetDetailCollection(Name, false); if (links == null) { if (change.Tags.Count == 0) { return; } links = item.GetDetailCollection(Name, true); } List <ITag> currentTags = GetCurrentTags(change.Group, links); IEnumerable <string> addedTags = GetAddedTags(currentTags, change.Tags); foreach (string tagName in addedTags) { ITag tag = change.Group.GetOrCreateTag(tagName); links.Add(tag); } foreach (ContentItem tag in currentTags) { if (!change.Tags.Contains(tag.Title)) { links.Remove(tag); } } }
private void ApplyChanges(AppliedTags change, ContentItem item) { DetailCollection links = item.GetDetailCollection(Name, false); if (links == null) { if (change.Tags.Count == 0) return; links = item.GetDetailCollection(Name, true); } List<ITag> currentTags = GetCurrentTags(change.Group, links); IEnumerable<string> addedTags = GetAddedTags(currentTags, change.Tags); foreach(string tagName in addedTags) { ITag tag = change.Group.GetOrCreateTag(tagName); links.Add(tag); } foreach(ContentItem tag in currentTags) { if (!change.Tags.Contains(tag.Title)) links.Remove(tag); } }