コード例 #1
0
        public EntryForApiContract(Artist artist, ContentLanguagePreference languagePreference, IEntryThumbPersister thumbPersister,
                                   EntryOptionalFields includedFields)
            : this(artist, languagePreference, includedFields)
        {
            ActivityDate = artist.ReleaseDate;
            ArtistType   = artist.ArtistType;
            CreateDate   = artist.CreateDate;
            Status       = artist.Status;

            if (includedFields.HasFlag(EntryOptionalFields.MainPicture) && artist.Picture != null)
            {
                MainPicture = EntryThumbForApiContract.Create(new EntryThumb(artist, artist.PictureMime), thumbPersister);
            }

            if (includedFields.HasFlag(EntryOptionalFields.Names))
            {
                Names = artist.Names.Select(n => new LocalizedStringContract(n)).ToArray();
            }

            if (includedFields.HasFlag(EntryOptionalFields.Tags))
            {
                Tags = artist.Tags.ActiveUsages.Select(u => new TagUsageForApiContract(u, languagePreference)).ToArray();
            }

            if (includedFields.HasFlag(EntryOptionalFields.WebLinks))
            {
                WebLinks = artist.WebLinks.Select(w => new ArchivedWebLinkContract(w)).ToArray();
            }
        }
コード例 #2
0
        public ReleaseEventForApiContract(ReleaseEvent rel, ContentLanguagePreference languagePreference, ReleaseEventOptionalFields fields, IEntryThumbPersister thumbPersister)
        {
            Category     = rel.Category;
            Date         = rel.Date;
            EndDate      = rel.EndDate;
            Id           = rel.Id;
            Name         = rel.TranslatedName[languagePreference];
            SeriesNumber = rel.SeriesNumber;
            SeriesSuffix = rel.SeriesSuffix;
            Status       = rel.Status;
            UrlSlug      = rel.UrlSlug;
            VenueName    = rel.VenueName;
            Version      = rel.Version;

            if (rel.HasSeries)
            {
                SeriesId = rel.Series.Id;
            }

            if (fields.HasFlag(ReleaseEventOptionalFields.AdditionalNames))
            {
                AdditionalNames = rel.Names.GetAdditionalNamesStringForLanguage(languagePreference);
            }

            if (fields.HasFlag(ReleaseEventOptionalFields.Artists))
            {
                Artists = rel.Artists.Select(a => new ArtistForEventContract(a, languagePreference)).ToArray();
            }

            if (fields.HasFlag(ReleaseEventOptionalFields.Description))
            {
                Description = rel.Description;
            }

            if (thumbPersister != null && fields.HasFlag(ReleaseEventOptionalFields.MainPicture))
            {
                MainPicture = EntryThumbForApiContract.Create(EntryThumb.Create(rel) ?? EntryThumb.Create(rel.Series), thumbPersister);
            }

            if (fields.HasFlag(ReleaseEventOptionalFields.Names))
            {
                Names = rel.Names.Select(n => new LocalizedStringContract(n)).ToArray();
            }

            if (fields.HasFlag(ReleaseEventOptionalFields.Series) && rel.HasSeries)
            {
                Series = new ReleaseEventSeriesContract(rel.Series, languagePreference);
            }

            if (fields.HasFlag(ReleaseEventOptionalFields.SongList) && rel.SongList != null)
            {
                SongList = new SongListBaseContract(rel.SongList);
            }

            if (fields.HasFlag(ReleaseEventOptionalFields.WebLinks))
            {
                WebLinks = rel.WebLinks.Select(w => new WebLinkForApiContract(w)).ToArray();
            }
        }
コード例 #3
0
        public EntryForApiContract(ReleaseEvent releaseEvent, ContentLanguagePreference languagePreference, IEntryThumbPersister thumbPersister,
                                   EntryOptionalFields includedFields)
            : this(releaseEvent, languagePreference, includedFields)
        {
            ActivityDate           = releaseEvent.Date.DateTime;
            EventCategory          = releaseEvent.InheritedCategory;
            ReleaseEventSeriesName = releaseEvent.Series?.TranslatedName[languagePreference];
            Status  = releaseEvent.Status;
            UrlSlug = releaseEvent.UrlSlug;

            if (includedFields.HasFlag(EntryOptionalFields.MainPicture))
            {
                MainPicture = EntryThumbForApiContract.Create(EntryThumb.Create(releaseEvent) ?? EntryThumb.Create(releaseEvent.Series), thumbPersister);
            }

            if (includedFields.HasFlag(EntryOptionalFields.WebLinks))
            {
                WebLinks = releaseEvent.WebLinks.Select(w => new ArchivedWebLinkContract(w)).ToArray();
            }
        }
コード例 #4
0
        public ReleaseEventSeriesForApiContract(ReleaseEventSeries series, ContentLanguagePreference languagePreference, ReleaseEventSeriesOptionalFields fields, IAggregatedEntryImageUrlFactory thumbPersister)
        {
            Category = series.Category;
            Id       = series.Id;
            Name     = series.TranslatedName[languagePreference];
            Status   = series.Status;
            UrlSlug  = series.UrlSlug;
            Version  = series.Version;

            if (fields.HasFlag(ReleaseEventSeriesOptionalFields.AdditionalNames))
            {
                AdditionalNames = series.Names.GetAdditionalNamesStringForLanguage(languagePreference);
            }

            if (fields.HasFlag(ReleaseEventSeriesOptionalFields.Description))
            {
                Description = series.Description;
            }

            if (fields.HasFlag(ReleaseEventSeriesOptionalFields.Events))
            {
                Events = series.Events.Select(e => new ReleaseEventForApiContract(e, languagePreference, ReleaseEventOptionalFields.None, thumbPersister)).ToArray();
            }

            if (thumbPersister != null && fields.HasFlag(ReleaseEventSeriesOptionalFields.MainPicture))
            {
                MainPicture = EntryThumbForApiContract.Create(EntryThumb.Create(series), thumbPersister);
            }

            if (fields.HasFlag(ReleaseEventSeriesOptionalFields.Names))
            {
                Names = series.Names.Select(n => new LocalizedStringContract(n)).ToArray();
            }

            if (fields.HasFlag(ReleaseEventSeriesOptionalFields.WebLinks))
            {
                WebLinks = series.WebLinks.Select(w => new WebLinkForApiContract(w)).ToArray();
            }
        }