示例#1
0
        public PartialFindResult <AlbumForUserForApiContract> GetAlbumCollection(
            int userId,
            string query = "",
            string tag   = null,
            int?artistId = null,
            [FromUri] PurchaseStatuses?purchaseStatuses = null,
            string releaseEventName = null,
            int start                      = 0,
            int maxResults                 = defaultMax,
            bool getTotalCount             = false,
            AlbumSortRule?sort             = null,
            NameMatchMode nameMatchMode    = NameMatchMode.Exact,
            AlbumOptionalFields fields     = AlbumOptionalFields.None,
            ContentLanguagePreference lang = ContentLanguagePreference.Default)
        {
            maxResults = Math.Min(maxResults, absoluteMax);
            query      = FindHelpers.GetMatchModeAndQueryForSearch(query, ref nameMatchMode);
            var ssl = WebHelper.IsSSL(Request);

            var queryParams = new AlbumCollectionQueryParams(userId, new PagingProperties(start, maxResults, getTotalCount))
            {
                ArtistId       = artistId ?? 0,
                FilterByStatus = purchaseStatuses != null?purchaseStatuses.Value.ToIndividualSelections().ToArray() : null,
                                     NameMatchMode    = nameMatchMode,
                                     Query            = query,
                                     ReleaseEventName = releaseEventName,
                                     Sort             = sort ?? AlbumSortRule.Name,
                                     Tag = tag
            };

            var albums = queries.GetAlbumCollection(queryParams, (afu, shouldShowCollectionStatus) =>
                                                    new AlbumForUserForApiContract(afu, lang, thumbPersister, ssl, fields, shouldShowCollectionStatus));

            return(albums);
        }
示例#2
0
        public PartialFindResult <AlbumForUserForApiContract> GetAlbumCollection(
            int id,
            string query = "",
            int?tagId    = null,
            string tag   = null,
            int?artistId = null,
            [FromUri] PurchaseStatuses?purchaseStatuses = null,
            int releaseEventId  = 0,
            DiscType albumTypes = DiscType.Unknown,
            [FromUri] AdvancedSearchFilter[] advancedFilters = null,
            int start                      = 0,
            int maxResults                 = defaultMax,
            bool getTotalCount             = false,
            AlbumSortRule?sort             = null,
            NameMatchMode nameMatchMode    = NameMatchMode.Exact,
            AlbumOptionalFields fields     = AlbumOptionalFields.None,
            ContentLanguagePreference lang = ContentLanguagePreference.Default)
        {
            maxResults = Math.Min(maxResults, absoluteMax);
            var textQuery = SearchTextQuery.Create(query, nameMatchMode);
            var ssl       = WebHelper.IsSSL(Request);

            var queryParams = new AlbumCollectionQueryParams(id, new PagingProperties(start, maxResults, getTotalCount))
            {
                AlbumType      = albumTypes,
                ArtistId       = artistId ?? 0,
                FilterByStatus = purchaseStatuses != null?purchaseStatuses.Value.ToIndividualSelections().ToArray() : null,
                                     TextQuery       = textQuery,
                                     ReleaseEventId  = releaseEventId,
                                     Sort            = sort ?? AlbumSortRule.Name,
                                     TagId           = tagId ?? 0,
                                     Tag             = tag,
                                     AdvancedFilters = advancedFilters
            };

            var albums = queries.GetAlbumCollection(queryParams, (afu, shouldShowCollectionStatus) =>
                                                    new AlbumForUserForApiContract(afu, lang, thumbPersister, ssl, fields, shouldShowCollectionStatus));

            return(albums);
        }