public PartialFindResult <ArtistForApiContract> GetList( string query = "", ArtistTypes artistTypes = ArtistTypes.Nothing, string tag = null, int?followedByUserId = null, EntryStatus?status = null, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, ArtistSortRule sort = ArtistSortRule.Name, NameMatchMode nameMatchMode = NameMatchMode.Exact, ArtistOptionalFields fields = ArtistOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { query = FindHelpers.GetMatchModeAndQueryForSearch(query, ref nameMatchMode); var types = ArtistHelper.GetArtistTypesFromFlags(artistTypes); var param = new ArtistQueryParams(query, types, start, Math.Min(maxResults, absoluteMax), false, getTotalCount, nameMatchMode, sort, false) { Tag = tag, UserFollowerId = followedByUserId ?? 0 }; param.Common.EntryStatus = status; var ssl = WebHelper.IsSSL(Request); var artists = service.FindArtists(s => new ArtistForApiContract(s, lang, thumbPersister, ssl, fields), param); return(artists); }
public PartialFindResult <ArtistForApiContract> GetList( string query = "", string artistTypes = null, string tag = null, int?followedByUserId = null, EntryStatus?status = null, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, ArtistSortRule sort = ArtistSortRule.Name, bool preferAccurateMatches = false, NameMatchMode nameMatchMode = NameMatchMode.Exact, ArtistOptionalFields fields = ArtistOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var textQuery = ArtistSearchTextQuery.Create(query, nameMatchMode); var types = EnumVal <ArtistType> .ParseMultiple(artistTypes); var param = new ArtistQueryParams(textQuery, types, start, Math.Min(maxResults, absoluteMax), false, getTotalCount, sort, preferAccurateMatches) { Tag = tag, UserFollowerId = followedByUserId ?? 0 }; param.Common.EntryStatus = status; var ssl = WebHelper.IsSSL(Request); var artists = service.FindArtists(s => new ArtistForApiContract(s, lang, thumbPersister, ssl, fields), param); return(artists); }
public ArtistForUserForApiContract(ArtistForUser artistForUser, ContentLanguagePreference languagePreference, IEntryThumbPersister thumbPersister, ArtistOptionalFields includedFields) { Artist = new ArtistForApiContract(artistForUser.Artist, languagePreference, thumbPersister, includedFields); }
public PartialFindResult <ArtistForUserForApiContract> GetFollowedArtists( int id, string query = "", [FromUri] int[] tagId = null, ArtistType artistType = ArtistType.Unknown, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, ArtistSortRule sort = ArtistSortRule.Name, NameMatchMode nameMatchMode = NameMatchMode.Auto, ArtistOptionalFields fields = ArtistOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { maxResults = Math.Min(maxResults, absoluteMax); var textQuery = ArtistSearchTextQuery.Create(query, nameMatchMode); var queryParams = new FollowedArtistQueryParams { UserId = id, ArtistType = artistType, Paging = new PagingProperties(start, maxResults, getTotalCount), SortRule = sort, TagIds = tagId, TextQuery = textQuery }; var artists = queries.GetArtists(queryParams, afu => new ArtistForUserForApiContract(afu, lang, thumbPersister, fields)); return(artists); }
public ArtistForUserForApiContract(ArtistForUser artistForUser, ContentLanguagePreference languagePreference, IAggregatedEntryImageUrlFactory thumbPersister, ArtistOptionalFields includedFields) { Artist = artistForUser != null ? new ArtistForApiContract(artistForUser.Artist, languagePreference, thumbPersister, includedFields) : null; }
public ArtistForUserForApiContract(ArtistForUser artistForUser, ContentLanguagePreference languagePreference, IEntryThumbPersister thumbPersister, bool ssl, ArtistOptionalFields includedFields) { Artist = new ArtistForApiContract(artistForUser.Artist, languagePreference, thumbPersister, ssl, includedFields); }
public ArtistForApiContract(Artist artist, ContentLanguagePreference languagePreference, IEntryThumbPersister thumbPersister, bool ssl, ArtistOptionalFields includedFields) { ArtistType = artist.ArtistType; BaseVoicebank = artist.BaseVoicebank != null ? new ArtistContract(artist.BaseVoicebank, languagePreference) : null; CreateDate = artist.CreateDate; DefaultName = artist.DefaultName; DefaultNameLanguage = artist.Names.SortNames.DefaultLanguage; Id = artist.Id; Name = artist.Names.SortNames[languagePreference]; PictureMime = artist.PictureMime; Status = artist.Status; Version = artist.Version; if (includedFields.HasFlag(ArtistOptionalFields.AdditionalNames)) { AdditionalNames = artist.Names.GetAdditionalNamesStringForLanguage(languagePreference); } if (includedFields.HasFlag(ArtistOptionalFields.ArtistLinks)) { ArtistLinks = artist.Groups.Select(g => new ArtistForArtistForApiContract(g, LinkDirection.ManyToOne, languagePreference)).ToArray(); } if (includedFields.HasFlag(ArtistOptionalFields.ArtistLinksReverse)) { ArtistLinksReverse = artist.Members.Select(m => new ArtistForArtistForApiContract(m, LinkDirection.OneToMany, languagePreference)).ToArray(); } if (includedFields.HasFlag(ArtistOptionalFields.Description)) { Description = artist.Description[languagePreference]; } if (includedFields.HasFlag(ArtistOptionalFields.Names)) { Names = artist.Names.Select(n => new LocalizedStringContract(n)).ToArray(); } if (includedFields.HasFlag(ArtistOptionalFields.Tags)) { Tags = artist.Tags.ActiveUsages.Select(u => new TagUsageForApiContract(u, languagePreference)).ToArray(); } if (thumbPersister != null && includedFields.HasFlag(ArtistOptionalFields.MainPicture) && !string.IsNullOrEmpty(artist.PictureMime)) { MainPicture = new EntryThumbForApiContract(new EntryThumb(artist, artist.PictureMime), thumbPersister, ssl); } if (includedFields.HasFlag(ArtistOptionalFields.WebLinks)) { WebLinks = artist.WebLinks.Select(w => new WebLinkForApiContract(w)).ToArray(); } }
public ArtistForApiContract GetOne(int id, ArtistOptionalFields fields = ArtistOptionalFields.None, ArtistRelationsFields relations = ArtistRelationsFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var artist = queries.GetWithMergeRecord(id, (a, m, ctx) => GetArtist(a, m, fields, relations, lang, ctx)); return(artist); }
public ArtistForApiContract(Artist artist, ContentLanguagePreference languagePreference, IEntryThumbPersister thumbPersister, bool ssl, ArtistOptionalFields includedFields) { ArtistType = artist.ArtistType; BaseVoicebank = artist.BaseVoicebank != null ? new ArtistContract(artist.BaseVoicebank, languagePreference) : null; CreateDate = artist.CreateDate; DefaultName = artist.DefaultName; DefaultNameLanguage = artist.Names.SortNames.DefaultLanguage; Id = artist.Id; Name = artist.Names.SortNames[languagePreference]; PictureMime = artist.PictureMime; Status = artist.Status; Version = artist.Version; if (languagePreference != ContentLanguagePreference.Default || includedFields.HasFlag(ArtistOptionalFields.AdditionalNames)) { AdditionalNames = artist.Names.GetAdditionalNamesStringForLanguage(languagePreference); } if (languagePreference != ContentLanguagePreference.Default) { LocalizedName = artist.Names.SortNames[languagePreference]; } if (includedFields.HasFlag(ArtistOptionalFields.Description)) Description = artist.Description; if (includedFields.HasFlag(ArtistOptionalFields.Groups)) Groups = artist.Groups.Select(g => new ArtistContract(g.Group, languagePreference)).ToArray(); if (includedFields.HasFlag(ArtistOptionalFields.Members)) Members = artist.Members.Select(m => new ArtistContract(m.Member, languagePreference)).ToArray(); if (includedFields.HasFlag(ArtistOptionalFields.Names)) Names = artist.Names.Select(n => new LocalizedStringContract(n)).ToArray(); if (includedFields.HasFlag(ArtistOptionalFields.Tags)) Tags = artist.Tags.Usages.Select(u => new TagUsageForApiContract(u)).ToArray(); if (thumbPersister != null && includedFields.HasFlag(ArtistOptionalFields.MainPicture) && !string.IsNullOrEmpty(artist.PictureMime)) { MainPicture = new EntryThumbForApiContract(new EntryThumb(artist, artist.PictureMime), thumbPersister, ssl); } if (includedFields.HasFlag(ArtistOptionalFields.WebLinks)) WebLinks = artist.WebLinks.Select(w => new ArchivedWebLinkContract(w)).ToArray(); }
private ArtistForApiContract GetArtist(Artist a, ArtistMergeRecord m, ArtistOptionalFields fields, ArtistRelationsFields relations, ContentLanguagePreference lang, IRepositoryContext <Artist> ctx) { var contract = new ArtistForApiContract(a, lang, thumbPersister, WebHelper.IsSSL(Request), fields); if (relations != ArtistRelationsFields.None) { contract.Relations = new ArtistRelationsQuery(ctx, lang).GetRelations(a, relations); } return(contract); }
private ArtistForApiContract GetArtist(Artist a, ArtistMergeRecord m, ArtistOptionalFields fields, ArtistRelationsFields relations, ContentLanguagePreference lang, IDatabaseContext <Artist> ctx) { var contract = new ArtistForApiContract(a, lang, _thumbPersister, fields); if (relations != ArtistRelationsFields.None) { contract.Relations = new ArtistRelationsQuery(ctx, lang, _cache, _thumbPersister).GetRelations(a, relations); } return(contract); }
public PartialFindResult <ArtistForUserForApiContract> GetFollowedArtists( int userId, ArtistType artistType = ArtistType.Unknown, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, ArtistOptionalFields fields = ArtistOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { maxResults = Math.Min(maxResults, absoluteMax); var ssl = WebHelper.IsSSL(Request); var queryParams = new FollowedArtistQueryParams { UserId = userId, ArtistType = artistType, Paging = new PagingProperties(start, maxResults, getTotalCount), }; var artists = queries.GetArtists(queryParams, afu => new ArtistForUserForApiContract(afu, lang, thumbPersister, ssl, fields)); return(artists); }
public PartialFindResult <ArtistForApiContract> GetList( string query = "", string artistTypes = null, bool allowBaseVoicebanks = true, [FromQuery(Name = "tagName[]")] string[] tagName = null, [FromQuery(Name = "tagId[]")] int[] tagId = null, bool childTags = false, int?followedByUserId = null, EntryStatus?status = null, [FromQuery(Name = "advancedFilters")] AdvancedSearchFilterParams[] advancedFilters = null, int start = 0, int maxResults = DefaultMax, bool getTotalCount = false, ArtistSortRule sort = ArtistSortRule.Name, bool preferAccurateMatches = false, NameMatchMode nameMatchMode = NameMatchMode.Exact, ArtistOptionalFields fields = ArtistOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var textQuery = ArtistSearchTextQuery.Create(query, nameMatchMode); var types = EnumVal <ArtistType> .ParseMultiple(artistTypes); var param = new ArtistQueryParams(textQuery, types, start, Math.Min(maxResults, AbsoluteMax), getTotalCount, sort, preferAccurateMatches) { Tags = tagName, TagIds = tagId, ChildTags = childTags, UserFollowerId = followedByUserId ?? 0, AllowBaseVoicebanks = allowBaseVoicebanks, AdvancedFilters = advancedFilters?.Select(advancedFilter => advancedFilter.ToAdvancedSearchFilter()).ToArray(), }; param.Common.EntryStatus = status; var artists = _service.FindArtists(s => new ArtistForApiContract(s, lang, _thumbPersister, fields), param); return(artists); }
public PartialFindResult<ArtistForUserForApiContract> GetFollowedArtists( int userId, ArtistType artistType = ArtistType.Unknown, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, ArtistOptionalFields fields = ArtistOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { maxResults = Math.Min(maxResults, absoluteMax); var ssl = WebHelper.IsSSL(Request); var queryParams = new FollowedArtistQueryParams { UserId = userId, ArtistType = artistType, Paging = new PagingProperties(start, maxResults, getTotalCount), }; var artists = queries.GetArtists(queryParams, afu => new ArtistForUserForApiContract(afu, lang, thumbPersister, ssl, fields)); return artists; }
private ArtistForApiContract GetArtist(Artist a, ArtistMergeRecord m, ArtistOptionalFields fields, ArtistRelationsFields relations, ContentLanguagePreference lang, IRepositoryContext<Artist> ctx) { var contract = new ArtistForApiContract(a, lang, thumbPersister, WebHelper.IsSSL(Request), fields); if (relations != ArtistRelationsFields.None) { contract.Relations = new ArtistRelationsQuery(ctx, lang).GetRelations(a, relations); } return contract; }
public PartialFindResult<ArtistForApiContract> GetList( string query = "", ArtistTypes artistTypes = ArtistTypes.Nothing, string tag = null, int? followedByUserId = null, EntryStatus? status = null, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, ArtistSortRule sort = ArtistSortRule.Name, NameMatchMode nameMatchMode = NameMatchMode.Exact, ArtistOptionalFields fields = ArtistOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { query = FindHelpers.GetMatchModeAndQueryForSearch(query, ref nameMatchMode); var types = ArtistHelper.GetArtistTypesFromFlags(artistTypes); var param = new ArtistQueryParams(query, types, start, Math.Min(maxResults, absoluteMax), false, getTotalCount, nameMatchMode, sort, false) { Tag = tag, UserFollowerId = followedByUserId ?? 0 }; param.Common.EntryStatus = status; var ssl = WebHelper.IsSSL(Request); var artists = service.FindArtists(s => new ArtistForApiContract(s, lang, thumbPersister, ssl, fields), param); return artists; }
public ArtistForApiContract GetOne(int id, ArtistOptionalFields fields = ArtistOptionalFields.None, ArtistRelationsFields relations = ArtistRelationsFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var artist = queries.GetWithMergeRecord(id, (a, m, ctx) => GetArtist(a, m, fields, relations, lang, ctx)); return artist; }