public ActionResult CategoryProducts(int categoryId) { CategoryProductsPageView viewModel = _shopService.GetCategoryProductPageViewFor(categoryId); ViewData["categories"] = viewModel.Categories; return(View(viewModel)); }
public CategoryProductsPageView GetCategoryProductPageViewFor(int categoryId) { IEnumerable <ProductView> products = _productService.GetAllProductsIn(categoryId).ConvertToProductViewList(); CategoryView category = _productService.GetCategoryBy(categoryId).ConvertToCategoryView(); IEnumerable <CategoryView> categories = _productService.GetAllCategories().ConvertToCategoryViewList(); CategoryProductsPageView categoryProductsPageView = new CategoryProductsPageView { Category = category, Products = products, Categories = categories }; return(categoryProductsPageView); }