using System; using System.Collections.Generic; using AutoMapper; using Umbraco.Core.Services; using Umbraco.Web.Models; namespace Umbraco.Web { /// /// A class that exposes methods used to query tag data in views /// public class TagQuery { private readonly ITagService _tagService; public TagQuery(ITagService tagService) { if (tagService == null) throw new ArgumentNullException("tagService"); _tagService = tagService; } /// /// Get every tag stored in the database (with optional group) /// public IEnumerable GetAllTags(string group = null) { return Mapper.Map>(_tagService.GetAllTags(group)); } /// /// Get all tags for content items (with optional group) /// /// /// public IEnumerable GetAllContentTags(string group = null) { return Mapper.Map>(_tagService.GetAllContentTags(group)); } /// /// Get all tags for media items (with optional group) /// /// /// public IEnumerable GetAllMediaTags(string group = null) { return Mapper.Map>(_tagService.GetAllMediaTags(group)); } /// /// Get all tags for member items (with optional group) /// /// /// public IEnumerable GetAllMemberTags(string group = null) { return Mapper.Map>(_tagService.GetAllMemberTags(group)); } /// /// Returns all tags attached to a property by entity id /// /// /// /// /// public IEnumerable GetTagsForProperty(int contentId, string propertyTypeAlias, string tagGroup = null) { return Mapper.Map>(_tagService.GetTagsForProperty(contentId, propertyTypeAlias, tagGroup)); } /// /// Returns all tags attached to an entity (content, media or member) by entity id /// /// /// /// public IEnumerable GetTagsForEntity(int contentId, string tagGroup = null) { return Mapper.Map>(_tagService.GetTagsForEntity(contentId, tagGroup)); } } }