public async Task <IActionResult> OnGetAsync(string categoryName)
        {
            var productList = await _catalogApi.GetCatalog();

            //CategoryList = productList.Select(p => p.Category).Distinct();

            CategoryList = from product in productList
                           orderby product.Category
                           group product by product.Category into Category
                           select new CategoryModel()
            {
                Name = Category.Key, Count = Category.Count()
            };

            if (!string.IsNullOrWhiteSpace(categoryName))
            {
                ProductList      = productList.Where(p => p.Category == categoryName);
                SelectedCategory = categoryName;
            }
            else
            {
                ProductList      = productList;
                SelectedCategory = "Tüm Ürünler";
            }

            return(Page());
        }
示例#2
0
        public async Task <IActionResult> OnGetAsync(string productId)
        {
            if (productId == null)
            {
                return(NotFound());
            }

            Product = await _catalogApi.GetCatalog(productId);

            if (Product == null)
            {
                return(NotFound());
            }
            return(Page());
        }
示例#3
0
        public async Task <IActionResult> OnGetAsync(string categoryName)
        {
            var productList = (await _catalogApi.GetCatalog()).ToList();

            CategoryList = productList.Select(x => x.Category).Distinct();
            if (!string.IsNullOrWhiteSpace(categoryName))
            {
                ProductList      = productList.Where(x => x.Category == categoryName);
                SelectedCategory = categoryName;
            }
            else
            {
                ProductList = productList;
            }
            return(Page());
        }
示例#4
0
        public async Task <IActionResult> OnGetAsync(string categoryName)
        {
            var productList = await _catalogApi.GetCatalog();

            CategoryList = productList.Select(p => p.Category).Distinct();

            // if category, display it. else display all products
            if (!string.IsNullOrWhiteSpace(categoryName))
            {
                ProductList      = productList.Where(p => p.Category == categoryName);
                SelectedCategory = categoryName;
            }
            else
            {
                ProductList = productList;
            }

            return(Page());
        }
示例#5
0
        public async Task <IActionResult> OnGetAsync(string categoryName)
        {
            var productList = await _catalogApi.GetCatalog();

            CategoryList = productList.Select(p => p.Category).Distinct();

            if (!string.IsNullOrEmpty(categoryName))
            {
                ProductList = await _catalogApi.GetCatalogByCategory(categoryName);

                SelectedCategory = categoryName;
            }
            else
            {
                ProductList = productList;
            }

            return(Page());
        }
        public async Task <IActionResult> OnGetAsync(string category)
        {
            CategoryList = new List <string>()
            {
            };

            if (!string.IsNullOrWhiteSpace(category))
            {
                ProductList = await catalogApi.GetCatalogByCategory(category);

                // SelectedCategory = CategoryList.FirstOrDefault(c => c.Id == categoryId.Value)?.Name;
            }
            else
            {
                ProductList = await catalogApi.GetCatalog();
            }

            return(Page());
        }
        public async Task <IActionResult> OnGetAsync(string categoryName, int pageNumber)
        {
            var productList = await _catalogApi.GetCatalog();

            CategoryList = productList.Select(p => p.Category).Distinct();

            if (!string.IsNullOrWhiteSpace(categoryName))
            {
                ProductList      = productList.Where(p => p.Category == categoryName);
                SelectedCategory = categoryName;
            }
            else if (pageNumber > 0)
            {
                ProductList = await _catalogApi.GetProductByPage(pageNumber);
            }
            else
            {
                ProductList = productList;
            }

            return(Page());
        }
示例#8
0
        public async Task <IActionResult> OnGetAsync()
        {
            ProductList = await _catalogApi.GetCatalog();

            return(Page());
        }
示例#9
0
        public async Task <IActionResult> OnGetAsync()
        {
            ProductList = await catalogApi.GetCatalog().ConfigureAwait(false);

            return(Page());
        }
        public async Task <IActionResult> IndexAsync()
        {
            var result = await _catalogApi.GetCatalog();

            return(View(result));
        }
 public async Task <IViewComponentResult> InvokeAsync()
 {
     return(View("_CategoryPartial", await _catalogApi.GetCatalog()));
 }