예제 #1
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;
        }
예제 #2
0
        public AlbumDisc(int discNumber, IEnumerable <SongInAlbumContract> songs, AlbumDiscPropertiesContract discProperties)
        {
            DiscNumber = discNumber;
            Songs      = songs.ToArray();

            IsVideo     = discProperties != null && discProperties.MediaType == DiscMediaType.Video;
            Name        = discProperties != null ? discProperties.Name : null;
            TotalLength = Songs.All(s => s.Song != null && s.Song.LengthSeconds > 0) ? TimeSpan.FromSeconds(Songs.Sum(s => s.Song.LengthSeconds)) : TimeSpan.Zero;
        }
예제 #3
0
        public AlbumDetailsContract(Album album, ContentLanguagePreference languagePreference)
            : base(album, languagePreference)
        {
            ArtistLinks     = album.Artists.Select(a => new ArtistForAlbumContract(a, languagePreference)).OrderBy(a => a.Name).ToArray();
            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);
            OriginalRelease = (album.OriginalRelease != null ? new AlbumReleaseContract(album.OriginalRelease) : null);
            Pictures        = album.Pictures.Select(p => new EntryPictureFileContract(p)).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)).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();

            TotalLength = Songs.All(s => s.Song != null && s.Song.LengthSeconds > 0) ? TimeSpan.FromSeconds(Songs.Sum(s => s.Song.LengthSeconds)) : TimeSpan.Zero;
        }
예제 #4
0
        public bool Equals(Group other)
        {
            if (ReferenceEquals(other, null))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            if (Path == other.Path)
            {
                if (Songs.Count == other.Songs.Count)
                {
                    return(Songs.All(song => other.Songs.Contains(song)));
                }
            }

            return(false);
        }