Exemplo n.º 1
0
        // GET: Product
        public ActionResult Index(int categoryId = 0)
        {
            List <IProduct> products = null;

            if (categoryId > 0)
            {
                products = _productCollection.GetProductsByCategoryID(categoryId);
            }
            else
            {
                products = _productCollection.GetAllProducts();
            }

            products.ForEach(p => p.Category = _categoryCollection.GetCategoryById(p.CategoryId));
            ProductIndexViewModel productIndexViewModel = new ProductIndexViewModel
            {
                Products = products,
            };

            return(View(productIndexViewModel));
        }