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 ArtistDetailsContract(Artist artist, ContentLanguagePreference languagePreference) : base(artist, languagePreference) { AllNames = string.Join(", ", artist.AllNames.Where(n => n != Name)); BaseVoicebank = artist.BaseVoicebank != null ? new ArtistContract(artist.BaseVoicebank, languagePreference) : null; CreateDate = artist.CreateDate; Description = artist.Description; Draft = artist.Status == EntryStatus.Draft; TranslatedName = new TranslatedStringContract(artist.TranslatedName); LatestAlbums = new AlbumContract[] {}; LatestSongs = new SongForApiContract[] {}; OwnerUsers = artist.OwnerUsers.Select(u => new UserContract(u.User)).ToArray(); Pictures = artist.Pictures.Select(p => new EntryPictureFileContract(p)).ToArray(); TopAlbums = new AlbumContract[] {}; TopSongs = new SongForApiContract[] {}; WebLinks = artist.WebLinks.Select(w => new WebLinkContract(w)).OrderBy(w => w.DescriptionOrUrl).ToArray(); CharacterDesigner = artist.ArtistLinksOfType(ArtistLinkType.CharacterDesigner, LinkDirection.ManyToOne, allowInheritance: true) .Select(g => new ArtistContract(g, languagePreference)).FirstOrDefault(); ChildVoicebanks = artist.CanHaveChildVoicebanks ? artist.ChildVoicebanks.Where(c => !c.Deleted) .Select(c => new ArtistContract(c, languagePreference)).ToArray() : new ArtistContract[0]; Groups = artist.ArtistLinksOfType(ArtistLinkType.Group, LinkDirection.ManyToOne) .Select(g => new ArtistContract(g, languagePreference)).OrderBy(g => g.Name).ToArray(); Illustrators = artist.ArtistLinksOfType(ArtistLinkType.Illustrator, LinkDirection.ManyToOne, allowInheritance: true) .Select(g => new ArtistContract(g, languagePreference)).ToArray(); IllustratorOf = artist.ArtistLinksOfType(ArtistLinkType.Illustrator, LinkDirection.OneToMany) .Select(g => new ArtistContract(g, languagePreference)).OrderBy(a => a.Name).ToArray(); Manager = artist.ArtistLinksOfType(ArtistLinkType.Manager, LinkDirection.ManyToOne, allowInheritance: true) .Select(g => new ArtistContract(g, languagePreference)).FirstOrDefault(); Members = artist.ArtistLinksOfType(ArtistLinkType.Group, LinkDirection.OneToMany) .Select(g => new ArtistContract(g, languagePreference)).OrderBy(g => g.Name).ToArray(); Tags = artist.Tags.ActiveUsages .Select(u => new TagUsageForApiContract(u, languagePreference)) .OrderByDescending(t => t.Count).ToArray(); VoiceProvider = artist.ArtistLinksOfType(ArtistLinkType.VoiceProvider, LinkDirection.ManyToOne, allowInheritance: true) .Select(g => new ArtistContract(g, languagePreference)).FirstOrDefault(); Voicebanks = artist.ArtistLinksOfType(ArtistLinkType.VoiceProvider, LinkDirection.OneToMany) .Select(g => new ArtistContract(g, languagePreference)).OrderBy(a => a.Name).ToArray(); }
public ArtistDetailsContract(Artist artist, ContentLanguagePreference languagePreference, IUserPermissionContext userContext, IEntryImagePersister imageStore) : base(artist, languagePreference) { AllNames = string.Join(", ", artist.AllNames.Where(n => n != Name)); BaseVoicebank = artist.BaseVoicebank != null ? new ArtistContract(artist.BaseVoicebank, languagePreference) : null; CanRemoveTagUsages = EntryPermissionManager.CanRemoveTagUsages(userContext, artist); CreateDate = artist.CreateDate; Description = artist.Description; Draft = artist.Status == EntryStatus.Draft; TranslatedName = new TranslatedStringContract(artist.TranslatedName); LatestAlbums = new AlbumForApiContract[] {}; LatestSongs = new SongForApiContract[] {}; OwnerUsers = artist.OwnerUsers.Select(u => new UserContract(u.User)).ToArray(); Pictures = artist.Pictures.Select(p => new EntryPictureFileContract(p, imageStore)).ToArray(); TopAlbums = new AlbumForApiContract[] {}; TopSongs = new SongForApiContract[] {}; WebLinks = artist.WebLinks.Select(w => new WebLinkContract(w)).OrderBy(w => w.DescriptionOrUrl).ToArray(); CharacterDesigner = artist.ArtistLinksOfType(ArtistLinkType.CharacterDesigner, LinkDirection.ManyToOne, allowInheritance: true) .Select(g => new ArtistContract(g, languagePreference)).FirstOrDefault(); CharacterDesignerOf = artist.ArtistLinksOfType(ArtistLinkType.CharacterDesigner, LinkDirection.OneToMany) .Select(g => new ArtistContract(g, languagePreference)).OrderBy(a => a.Name).ToArray(); if (artist.CanHaveChildVoicebanks) { var children = artist.ChildVoicebanks .Where(c => !c.Deleted) .Select(c => new ArtistContract(c, languagePreference)) .ToArray(); // Show child voicebanks with release date first ChildVoicebanks = children .Where(c => c.ReleaseDate.HasValue) .OrderBy(c => c.ReleaseDate) .Concat(children.Where(c => !c.ReleaseDate.HasValue)) .ToArray(); } else { ChildVoicebanks = new ArtistContract[0]; } Groups = artist.ArtistLinksOfType(ArtistLinkType.Group, LinkDirection.ManyToOne) .Select(g => new ArtistContract(g, languagePreference)).OrderBy(g => g.Name).ToArray(); Illustrators = artist.ArtistLinksOfType(ArtistLinkType.Illustrator, LinkDirection.ManyToOne, allowInheritance: true) .Select(g => new ArtistContract(g, languagePreference)).ToArray(); IllustratorOf = artist.ArtistLinksOfType(ArtistLinkType.Illustrator, LinkDirection.OneToMany) .Select(g => new ArtistContract(g, languagePreference)).OrderBy(a => a.Name).ToArray(); Manager = artist.ArtistLinksOfType(ArtistLinkType.Manager, LinkDirection.ManyToOne, allowInheritance: true) .Select(g => new ArtistContract(g, languagePreference)).FirstOrDefault(); Members = artist.ArtistLinksOfType(ArtistLinkType.Group, LinkDirection.OneToMany) .Select(g => new ArtistContract(g, languagePreference)).OrderBy(g => g.Name).ToArray(); Tags = artist.Tags.ActiveUsages .Select(u => new TagUsageForApiContract(u, languagePreference)) .OrderByDescending(t => t.Count).ToArray(); VoiceProviders = artist.ArtistLinksOfType(ArtistLinkType.VoiceProvider, LinkDirection.ManyToOne, allowInheritance: true) .Select(g => new ArtistContract(g, languagePreference)).OrderBy(a => a.Name).ToArray(); Voicebanks = artist.ArtistLinksOfType(ArtistLinkType.VoiceProvider, LinkDirection.OneToMany) .Select(g => new ArtistContract(g, languagePreference)).OrderBy(a => a.Name).ToArray(); }
public RatedSongForUserForApiContract(FavoriteSongForUser ratedSong, ContentLanguagePreference languagePreference, SongOptionalFields fields) { Date = ratedSong.Date; Rating = ratedSong.Rating; Song = new SongForApiContract(ratedSong.Song, null, languagePreference, fields); }
private void InsertSong(SongForApiContract id) { logger.Info("Found new Song: " + id.Name); foreach (ArtistForSongContract artistForSongContract in id.Artists) { if (artistForSongContract.Artist != null) { if (!TestForArtist(artistForSongContract.Artist.Id.Value)) { InsertArtist(artistForSongContract.Artist); } } if (insertSongArtist == null) { insertSongArtist = connection.CreateCommand(); insertSongArtist.CommandText = "INSERT INTO dump_vocadb.songartists " + "(id,trackid,artistid,categories,effectiveroles,iscustomname,issupport,name,roles) " + "VALUES " + "(@id,@ti,@ai,@categories,@er,@icn,@is,@name,@roles)"; insertSongArtist.Parameters.Add("@id", NpgsqlDbType.Integer); insertSongArtist.Parameters.Add("@ti", NpgsqlDbType.Integer); insertSongArtist.Parameters.Add("@ai", NpgsqlDbType.Integer); insertSongArtist.Parameters.Add("@categories", NpgsqlDbType.Varchar); insertSongArtist.Parameters.Add("@er", NpgsqlDbType.Varchar); insertSongArtist.Parameters.Add("@icn", NpgsqlDbType.Boolean); insertSongArtist.Parameters.Add("@is", NpgsqlDbType.Boolean); insertSongArtist.Parameters.Add("@name", NpgsqlDbType.Varchar); insertSongArtist.Parameters.Add("@roles", NpgsqlDbType.Varchar); } insertSongArtist.Parameters["@id"].Value = artistForSongContract.Id; insertSongArtist.Parameters["@ti"].Value = id.Id; insertSongArtist.Parameters["@ai"].Value = artistForSongContract.Artist != null ? artistForSongContract.Artist.Id : -1; insertSongArtist.Parameters["@categories"].Value = artistForSongContract.Categories; insertSongArtist.Parameters["@er"].Value = artistForSongContract.EffectiveRoles; insertSongArtist.Parameters["@icn"].Value = artistForSongContract.IsCustomName.Value; insertSongArtist.Parameters["@is"].Value = artistForSongContract.IsSupport.Value; insertSongArtist.Parameters["@name"].Value = artistForSongContract.Name; insertSongArtist.Parameters["@roles"].Value = artistForSongContract.Roles; insertSongArtist.ExecuteNonQuery(); } if (insertSong == null) { insertSong = connection.CreateCommand(); insertSong.CommandText = "INSERT INTO dump_vocadb.songs " + "(id,artiststring,createdate,defaultname,defaultnamelanguage,favoritedtimes,lengthseconds," + " name,publishdate,pvservices,ratingscore,songtype,status,version) " + "VALUES " + "(@id,@as,@cd,@dn,@dnl,@ft,@ls,@name,@pd,@pvs,@rs,@st,@status,@version)"; insertSong.Parameters.Add("@id", NpgsqlDbType.Integer); insertSong.Parameters.Add("@as", NpgsqlDbType.Varchar); insertSong.Parameters.Add("@cd", NpgsqlDbType.Timestamp); insertSong.Parameters.Add("@dn", NpgsqlDbType.Varchar); insertSong.Parameters.Add("@dnl", NpgsqlDbType.Varchar); insertSong.Parameters.Add("@ft", NpgsqlDbType.Integer); insertSong.Parameters.Add("@ls", NpgsqlDbType.Integer); insertSong.Parameters.Add("@name", NpgsqlDbType.Varchar); insertSong.Parameters.Add("@pd", NpgsqlDbType.Timestamp); insertSong.Parameters.Add("@pvs", NpgsqlDbType.Varchar); insertSong.Parameters.Add("@rs", NpgsqlDbType.Integer); insertSong.Parameters.Add("@st", NpgsqlDbType.Varchar); insertSong.Parameters.Add("@status", NpgsqlDbType.Varchar); insertSong.Parameters.Add("@version", NpgsqlDbType.Integer); } insertSong.Parameters["@id"].Value = id.Id.Value; insertSong.Parameters["@as"].Value = id.ArtistString; insertSong.Parameters["@cd"].Value = id.CreateDate; insertSong.Parameters["@dn"].Value = id.DefaultName; insertSong.Parameters["@dnl"].Value = id.DefaultNameLanguage; insertSong.Parameters["@ft"].Value = id.FavoritedTimes; insertSong.Parameters["@ls"].Value = id.LengthSeconds; insertSong.Parameters["@name"].Value = id.Name; if (id.PublishDate.HasValue) { insertSong.Parameters["@pd"].Value = id.PublishDate; } else { insertSong.Parameters["@pd"].Value = DBNull.Value; } insertSong.Parameters["@pvs"].Value = id.PvServices; insertSong.Parameters["@rs"].Value = id.RatingScore; insertSong.Parameters["@st"].Value = id.SongType; insertSong.Parameters["@status"].Value = id.Status; insertSong.Parameters["@version"].Value = id.Version; insertSong.ExecuteNonQuery(); }