public AlbumCollection(UserContract user, AlbumCollectionRouteParams routeParams) { User = user; RouteParams = routeParams; FilterByPurchaseStatus = routeParams.purchaseStatus ?? PurchaseStatus.Nothing; }
public ActionResult AlbumCollection(AlbumCollectionRouteParams routeParams) { var id = routeParams.id; if (id == invalidId) return NoId(); if (Request.IsAjaxRequest()) { return AlbumCollectionPaged(routeParams); } else { return View(new AlbumCollection(Service.GetUser(id), routeParams)); } }
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); }
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); }