public async Task <IActionResult> Products(int pageNumber = 1, int pageSize = 10, string orderBy = "", bool isAscending = true)
        {
            _logger.LogInformation("Request received for [{action}] GET action", nameof(ProductsController.Products));

            if (string.IsNullOrWhiteSpace(orderBy))
            {
                orderBy = nameof(Product.DateCreated);
            }

            var sortingParameters = new SortingParameters();

            sortingParameters.Add(orderBy, isAscending);
            var list = await _catalogService.GetProductsPagedAsync(null, sortingParameters, pageNumber, pageSize);

            var lkpCategories     = _lookupServiceFactory.Create <ProductCategory>();
            var productCategories = await lkpCategories.GetAllAsync();

            var vm = new ProductsViewModel
            {
                Products   = new PagedCollection <ProductDTO>(Mapper.Map(list).ToANew <IEnumerable <ProductDTO> >(), list.TotalItemCount, list.PageNumber, list.PageSize),
                Categories = productCategories.ToDictionary(key => key.Id, value => value.Name)
            };

            return(View(vm));
        }
        public async Task <IActionResult> Categories()
        {
            var lkpService        = _lookupServiceFactory.Create <ProductCategory>();
            var productCategories = await lkpService.GetAllAsync();

            var vm = new ProductCategoriesViewModel()
            {
                ProductCategories = Mapper.Map(productCategories).ToANew <IEnumerable <ProductCategoriesViewModel.ProductCategoryDTO> >()
            };

            return(View(vm));
        }
        public async Task <IActionResult> Index(string categorySlug)
        {
            var sortingParameters = new SortingParameters();

            sortingParameters.Add("Id", false);

            Expression <Func <Product, bool> > predicate = categorySlug == null ? (Expression <Func <Product, bool> >)null : o => o.ProductCategory.Slug == categorySlug;

            var products   = _catalogService.GetProductsPagedAsync(predicate, sortingParameters, 1, 10);
            var categories = _lookupServiceFactory.Create <ProductCategory>().GetAllAsync();
            await Task.WhenAll(products, categories);

            var vm = new IndexViewModel
            {
                Products   = Mapper.Map(await products).ToANew <IEnumerable <ProductDTO> >(),
                Categories = Mapper.Map(await categories).ToANew <IEnumerable <CategoryDTO> >()
            };

            return(View(vm));
        }