public SongListForApiContract(SongList list, ContentLanguagePreference languagePreference, IUserIconFactory userIconFactory, IAggregatedEntryImageUrlFactory imagePersister,
                                      SongListOptionalFields fields) : base(list)
        {
            ParamIs.NotNull(() => list);

            Author    = new UserForApiContract(list.Author, userIconFactory, UserOptionalFields.None);
            Deleted   = list.Deleted;
            EventDate = list.EventDate;
            Status    = list.Status;

            if (fields.HasFlag(SongListOptionalFields.Description))
            {
                Description = list.Description;
            }

            if (fields.HasFlag(SongListOptionalFields.Events))
            {
                Events = list.Events.Select(e => new ReleaseEventForApiContract(e, languagePreference, ReleaseEventOptionalFields.Venue, imagePersister)).OrderBy(e => e.Date).ThenBy(e => e.Name).ToArray();
            }

            if (fields.HasFlag(SongListOptionalFields.MainPicture))
            {
                MainPicture = list.Thumb != null ? new EntryThumbForApiContract(list.Thumb, imagePersister) : null;
            }

            if (fields.HasFlag(SongListOptionalFields.Tags))
            {
                Tags = list.Tags.ActiveUsages.Select(u => new TagUsageForApiContract(u, languagePreference)).OrderByDescending(u => u.Count).ToArray();
            }
        }
Пример #2
0
        public SongListForApiContract(SongList list, IUserIconFactory userIconFactory, IEntryImagePersister imagePersister,
                                      bool ssl, SongListOptionalFields fields) : base(list)
        {
            ParamIs.NotNull(() => list);

            Author    = new UserForApiContract(list.Author, userIconFactory, UserOptionalFields.None);
            EventDate = list.EventDate;

            if (fields.HasFlag(SongListOptionalFields.MainPicture))
            {
                MainPicture = (list.Thumb != null ? new EntryThumbForApiContract(list.Thumb, imagePersister, ssl) : null);
            }
        }