Example #1
0
        public async Task <ActionResult> Index(
            [FromQuery(Name = "p")] int?page,
            [FromQuery(Name = "c")] int?pageCount)
        {
            var currPage     = page ?? 1;
            var countPerPage = pageCount == null || pageCount <= 0 ? 15 : pageCount.Value;

            SortPageResult <Product> result =
                await _shopManager.GetSortFilterPageAsync(ItemTypeSelector.Enabled, currPage, countPerPage);

            var recentProductNumber = 4;
            IEnumerable <Product> recentProducts = await _shopManager.GetNewProducts(recentProductNumber);

            var model = new IndexViewModel()
            {
                RecentItems  = _mapper.Map <IEnumerable <ProductDto> >(recentProducts),
                Items        = _mapper.Map <IEnumerable <ProductDto> >(result.FilteredData),
                ItemCount    = result.TotalN,
                CurrentPage  = currPage,
                CountPerPage = countPerPage
            };

            return(View(model));
        }