public IActionResult Products(int catId) { NorthwindDb db = new NorthwindDb(_connectionString); ProductsViewModel vm = new ProductsViewModel(); vm.Products = db.GetProductsForCategory(catId); vm.CategoryName = db.GetCategoryName(catId); return(View(vm)); }
public ActionResult Products(int catid) { NorthwindDb db = new NorthwindDb(connectionString); Category category = db.GetCategoryById(catid); IEnumerable <Product> products = db.GetProductsForCategory(catid); ProductsViewModel viewModel = new ProductsViewModel(); viewModel.Products = products; viewModel.Category = category; return(View(viewModel)); }