示例#1
0
        public static ProductCategoryLiquidVeiwModel AsLiquidAdapted(this PaginatedProductCategory model)
        {
            var adaptedCat = Mapper.Map <ProductCategoryLiquidVeiwModel>(model.ProductCategory);

            adaptedCat.Products      = model.Products.AsLiquidAdapted();
            adaptedCat.AllPagesCount = model.AllPagesCount;
            adaptedCat.CurrentPage   = model.CurrentPage;
            return(adaptedCat);
        }
示例#2
0
        public async Task <PaginatedProductCategory> ListByCategoryAsync(string productCategoryUrl, int pageNumber)
        {
            var category = await _productCategoryDataService.Query.FirstAsync(x => x.Url == productCategoryUrl);

            var query = _accessManager
                        .Filter(_productDataService.Query.Where(x => x.PrimaryCategoryId == category.Id))
                        .OrderByDescending(x => x.PublishDateTime);

            var retValue = new PaginatedProductCategory
            {
                AllPagesCount   = query.GetAllPagesCount(FrontEndDeveloperOptions.Instance.Pagination.Default),
                CurrentPage     = pageNumber,
                ProductCategory = category,
                Products        = await query
                                  .Paginate(_pageSize, pageNumber)
                                  .ToListAsync()
            };

            retValue.Products.ForEach(
                FetchAvalailbleDiscounts);
            return(retValue);
        }