public TagContract FindTag(string tagName) { ParamIs.NotNullOrEmpty(() => tagName); return(HandleQuery(session => { Tag[] tags; if (tagName.Length < 3) { tags = session.Query <Tag>().Where(t => t.Name == tagName).Take(1).ToArray(); } else { tags = session.Query <Tag>().Where(t => t.Name.Contains(tagName)).Take(10).ToArray(); } var match = tags.FirstOrDefault(t => t.Name.Equals(tagName, System.StringComparison.InvariantCultureIgnoreCase)); if (match == null) { match = tags.FirstOrDefault(); } if (match == null) { return null; } return new TagContract(match); })); }
public TagMapping(Tag tag, string sourceTag) : this() { ParamIs.NotNull(() => tag); ParamIs.NotNullOrEmpty(() => sourceTag); Tag = tag; SourceTag = sourceTag; }
public OldUsername(User user, string oldName) : this() { ParamIs.NotNull(() => user); ParamIs.NotNullOrEmpty(() => oldName); User = user; OldName = oldName; }
public SongOEmbedResponse(SongForApiContract song, int width, int height, string html) { ParamIs.NotNull(() => song); ParamIs.NotNullOrEmpty(() => html); AuthorName = song.ArtistString; ThumbnailUrl = song.ThumbUrl; Title = song.Name; Height = height; Html = html; Width = width; }
public SongOEmbedResponse(SongContract song, int width, int height, string html) { ParamIs.NotNull(() => song); ParamIs.NotNullOrEmpty(() => html); author_name = song.ArtistString; thumbnail_url = song.ThumbUrl; title = song.Name; this.height = height; this.html = html; this.width = width; }
public TagForEditContract GetTagForEdit(string tagName) { ParamIs.NotNullOrEmpty(() => tagName); return(HandleQuery(session => { var inUse = session.Query <ArtistTagUsage>().Any(a => a.Tag.Name == tagName && !a.Artist.Deleted) || session.Query <AlbumTagUsage>().Any(a => a.Tag.Name == tagName && !a.Album.Deleted) || session.Query <SongTagUsage>().Any(a => a.Tag.Name == tagName && !a.Song.Deleted); var contract = new TagForEditContract(session.Load <Tag>(tagName), session.Query <Tag>().Select(t => t.CategoryName).OrderBy(t => t).Distinct().ToArray(), !inUse); return contract; })); }
public void Delete(string name) { ParamIs.NotNullOrEmpty(() => name); PermissionContext.VerifyPermission(PermissionToken.DeleteEntries); HandleTransaction(session => { var tag = session.Load <Tag>(name); tag.Delete(); AuditLog(string.Format("deleted {0}", tag), session); session.Delete(tag); }); }