Example #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;
        }
Example #2
0
        public ActionResult AlbumCollectionPaged(AlbumCollectionRouteParams routeParams)
        {
            var id = routeParams.id;

            if (id == invalidId)
                return NoId();

            const int entriesPerPage = 50;
            var pageIndex = (routeParams.page - 1) ?? 0;
            var queryParams = new AlbumCollectionQueryParams(id, PagingProperties.CreateFromPage(pageIndex, entriesPerPage, routeParams.count == 0)) {
                FilterByStatus = routeParams.purchaseStatus ?? PurchaseStatus.Nothing
            };
            var albums = Service.GetAlbumCollection(queryParams);
            routeParams.count = (albums.TotalCount != 0 ? albums.TotalCount : routeParams.count);
            var paged = new PagingData<AlbumForUserContract>(albums.Items.ToPagedList(pageIndex, entriesPerPage, routeParams.count), id, "AlbumCollection", "ui-tabs-1");
            paged.RouteValues = new RouteValueDictionary(new { action = "AlbumCollection", id, count = routeParams.count, purchaseStatus = routeParams.purchaseStatus });

            return PartialView("AlbumCollectionPaged", paged);
        }
Example #3
0
        public ActionResult AlbumCollectionPaged(AlbumCollectionRouteParams routeParams)
        {
            var id = routeParams.id;

            if (id == invalidId)
                return NoId();

            int pageSize = Math.Min(routeParams.pageSize ?? 50, 200);
            var pageIndex = (routeParams.page - 1) ?? 0;
            var queryParams = new AlbumCollectionQueryParams(id, PagingProperties.CreateFromPage(pageIndex, pageSize, routeParams.totalCount == 0)) {
                FilterByStatus = routeParams.purchaseStatus != null ? new[] { routeParams.purchaseStatus.Value } : null
            };
            var albums = Data.GetAlbumCollection(queryParams);
            routeParams.totalCount = (albums.TotalCount != 0 ? albums.TotalCount : routeParams.totalCount);
            var paged = new PagingData<AlbumForUserContract>(albums.Items.ToPagedList(pageIndex, pageSize, routeParams.totalCount), id, "AlbumCollection", "ui-tabs-1", addTotalCount: true);
            paged.RouteValues = new RouteValueDictionary(new { routeParams.purchaseStatus, pageSize });

            return PartialView("AlbumCollectionPaged", paged);
        }