コード例 #1
0
 /// <summary>
 /// Updates the tag repository with any tag enabled properties and their values
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="tagRepo"></param>
 protected void UpdatePropertyTags(IContentBase entity, ITagRepository tagRepo)
 {
     foreach (var tagProp in entity.Properties.Where(x => x.TagSupport.Enable))
     {
         if (tagProp.TagSupport.Behavior == PropertyTagBehavior.Remove)
         {
             //remove the specific tags
             tagRepo.RemoveTagsFromProperty(
                 entity.Id,
                 tagProp.PropertyTypeId,
                 tagProp.TagSupport.Tags.Select(x => new Tag {
                 Text = x.Item1, Group = x.Item2
             }));
         }
         else
         {
             //assign the tags
             tagRepo.AssignTagsToProperty(
                 entity.Id,
                 tagProp.PropertyTypeId,
                 tagProp.TagSupport.Tags.Select(x => new Tag {
                 Text = x.Item1, Group = x.Item2
             }),
                 tagProp.TagSupport.Behavior == PropertyTagBehavior.Replace);
         }
     }
 }