Ejemplo n.º 1
0
        public SongDetailsContract(Song song, ContentLanguagePreference languagePreference,
                                   SongListBaseContract[] pools, ISpecialTags specialTags, IUserPermissionContext userContext, IEntryThumbPersister thumbPersister)
        {
            Song = new SongContract(song, languagePreference);

            AdditionalNames            = song.Names.GetAdditionalNamesStringForLanguage(languagePreference);
            Albums                     = song.OnAlbums.OrderBy(a => a.OriginalReleaseDate.SortableDateTime).Select(a => new AlbumContract(a, languagePreference)).ToArray();
            AlternateVersions          = song.AlternateVersions.Select(s => new SongContract(s, languagePreference, getThumbUrl: false)).OrderBy(s => s.PublishDate).ToArray();
            Artists                    = song.Artists.Select(a => new ArtistForSongContract(a, languagePreference)).OrderBy(a => a.Name).ToArray();
            ArtistString               = song.ArtistString[languagePreference];
            CanEditPersonalDescription = EntryPermissionManager.CanEditPersonalDescription(userContext, song);
            CanRemoveTagUsages         = EntryPermissionManager.CanRemoveTagUsages(userContext, song);
            CreateDate                 = song.CreateDate;
            Deleted                    = song.Deleted;
            LikeCount                  = song.UserFavorites.Count(f => f.Rating == SongVoteRating.Like);
            LyricsFromParents          = song.GetLyricsFromParents(specialTags).Select(l => new LyricsForSongContract(l, false)).ToArray();
            Notes           = song.Notes;
            OriginalVersion = (song.OriginalVersion != null && !song.OriginalVersion.Deleted ?
                               new SongForApiContract(song.OriginalVersion, null, languagePreference, SongOptionalFields.AdditionalNames | SongOptionalFields.ThumbUrl) : null);

            PVs                     = song.PVs.Select(p => new PVContract(p)).ToArray();
            ReleaseEvent            = song.ReleaseEvent != null && !song.ReleaseEvent.Deleted ? new ReleaseEventForApiContract(song.ReleaseEvent, languagePreference, ReleaseEventOptionalFields.None, thumbPersister, true) : null;
            PersonalDescriptionText = song.PersonalDescriptionText;
            var author = song.PersonalDescriptionAuthor;

            PersonalDescriptionAuthor = author != null ? new ArtistForApiContract(author, languagePreference, thumbPersister, true, ArtistOptionalFields.MainPicture) : null;
            SubjectsFromParents       = song.GetCharactersFromParents().Select(c => new ArtistForSongContract(c, languagePreference)).ToArray();
            Tags           = song.Tags.ActiveUsages.Select(u => new TagUsageForApiContract(u, languagePreference)).OrderByDescending(t => t.Count).ToArray();
            TranslatedName = new TranslatedStringContract(song.TranslatedName);
            WebLinks       = song.WebLinks.Select(w => new WebLinkContract(w)).OrderBy(w => w.DescriptionOrUrl).ToArray();

            Pools = pools;
        }
Ejemplo n.º 2
0
        public AlbumDetailsContract(Album album, ContentLanguagePreference languagePreference, IUserPermissionContext userContext, IAggregatedEntryImageUrlFactory thumbPersister,
                                    Func <Song, SongVoteRating?> getSongRating = null, Tag discTypeTag = null)
            : base(album, languagePreference)
        {
            ArtistLinks = album.Artists.Select(a => new ArtistForAlbumContract(a, languagePreference)).OrderBy(a => a.Name).ToArray();
            CanEditPersonalDescription = EntryPermissionManager.CanEditPersonalDescription(userContext, album);
            CanRemoveTagUsages         = EntryPermissionManager.CanRemoveTagUsages(userContext, album);
            Description     = album.Description;
            Discs           = album.Songs.Any(s => s.DiscNumber > 1) ? album.Discs.Select(d => new AlbumDiscPropertiesContract(d)).ToDictionary(a => a.DiscNumber) : new Dictionary <int, AlbumDiscPropertiesContract>(0);
            DiscTypeTypeTag = discTypeTag != null ? new TagBaseContract(discTypeTag, languagePreference) : null;
            OriginalRelease = (album.OriginalRelease != null ? new AlbumReleaseContract(album.OriginalRelease, languagePreference) : null);
            Pictures        = album.Pictures.Select(p => new EntryPictureFileContract(p, thumbPersister)).ToArray();
            PVs             = album.PVs.Select(p => new PVContract(p)).ToArray();
            Songs           = album.Songs
                              .OrderBy(s => s.DiscNumber).ThenBy(s => s.TrackNumber)
                              .Select(s => new SongInAlbumContract(s, languagePreference, false, rating: getSongRating?.Invoke(s.Song)))
                              .ToArray();
            Tags     = album.Tags.ActiveUsages.Select(u => new TagUsageForApiContract(u, languagePreference)).OrderByDescending(t => t.Count).ToArray();
            WebLinks = album.WebLinks.Select(w => new WebLinkContract(w)).OrderBy(w => w.DescriptionOrUrl).ToArray();

            PersonalDescriptionText = album.PersonalDescriptionText;
            var author = album.PersonalDescriptionAuthor;

            PersonalDescriptionAuthor = author != null ? new ArtistForApiContract(author, languagePreference, thumbPersister, ArtistOptionalFields.MainPicture) : null;

            TotalLength = Songs.All(s => s.Song != null && s.Song.LengthSeconds > 0) ? TimeSpan.FromSeconds(Songs.Sum(s => s.Song.LengthSeconds)) : TimeSpan.Zero;
        }
        public ReleaseEventDetailsContract(ReleaseEvent releaseEvent, ContentLanguagePreference languagePreference,
                                           IUserPermissionContext userContext, IUserIconFactory userIconFactory, IEntryTypeTagRepository entryTypeTags = null)
            : base(releaseEvent, languagePreference, true, true)
        {
            ParamIs.NotNull(() => releaseEvent);

            CanRemoveTagUsages  = EntryPermissionManager.CanRemoveTagUsages(userContext, releaseEvent);
            DefaultNameLanguage = releaseEvent.TranslatedName.DefaultLanguage;
            PVs            = releaseEvent.PVs.Select(p => new PVContract(p)).ToArray();
            SeriesNumber   = releaseEvent.SeriesNumber;
            SeriesSuffix   = releaseEvent.SeriesSuffix;
            Tags           = releaseEvent.Tags.ActiveUsages.Select(u => new TagUsageForApiContract(u, languagePreference)).OrderByDescending(t => t.Count).ToArray();
            TranslatedName = new TranslatedStringContract(releaseEvent.TranslatedName);
            WebLinks       = releaseEvent.WebLinks.Select(w => new WebLinkContract(w)).OrderBy(w => w.DescriptionOrUrl).ToArray();

            var categoryTag = entryTypeTags?.GetTag(Domain.EntryType.ReleaseEvent, InheritedCategory);

            InheritedCategoryTag = categoryTag != null ? new TagBaseContract(categoryTag, languagePreference) : null;

            Albums = releaseEvent.Albums
                     .Select(a => new AlbumContract(a, languagePreference))
                     .OrderBy(a => a.Name)
                     .ToArray();

            Artists = releaseEvent.AllArtists
                      .Select(a => new ArtistForEventContract(a, languagePreference))
                      .OrderBy(a => a.Artist != null ? a.Artist.Name : a.Name)
                      .ToArray();

            Songs = releaseEvent.Songs
                    .Select(s => new SongForApiContract(s, languagePreference, SongOptionalFields.AdditionalNames | SongOptionalFields.ThumbUrl))
                    .OrderBy(s => s.Name)
                    .ToArray();

            UsersAttending = releaseEvent.Users
                             .Where(u => u.RelationshipType == UserEventRelationshipType.Attending)
                             .Select(u => new UserForApiContract(u.User, userIconFactory, UserOptionalFields.MainPicture))
                             .ToArray();

            if (releaseEvent.SongList != null)
            {
                SongListSongs = releaseEvent.SongList.SongLinks.OrderBy(s => s.Order).Select(s => new SongInListContract(s, languagePreference)).ToArray();
            }
        }
Ejemplo n.º 4
0
 public EntryWithTagUsagesContract(IEntryBase entry, IEnumerable <TagUsage> tagUsages, ContentLanguagePreference languagePreference, IUserPermissionContext userContext, IUserIconFactory userIconFactory)
     : base(entry)
 {
     CanRemoveTagUsages = EntryPermissionManager.CanRemoveTagUsages(userContext, entry);
     TagUsages          = tagUsages.Select(u => new TagUsageWithVotesContract(u, languagePreference, userIconFactory)).ToArray();
 }
Ejemplo n.º 5
0
        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();
        }