public IActionResult Index(int category)
        {
            var model = new ProductListViewmodel
            {
                Products = category > 0 ? _productService.GetByCategory(category).Data : _productService.GetAll().Data
            };

            return(View(model));
        }
예제 #2
0
        public ActionResult Index(string Category = null)
        {
            List <Product>         products;
            List <ProductCategory> categories = productCategoryContext.Collection().ToList();

            if (Category == null)
            {
                products = context.Collection().ToList();
            }
            else
            {
                products = context.Collection().Where(p => p.Category == Category).ToList();
            }
            ProductListViewmodel model = new ProductListViewmodel();

            model.Products          = products;
            model.ProductCategories = categories;
            return(View(model));
        }