public ActionResult Stock() { ProductsDb dbProduct = new ProductsDb(); ModelState.Clear(); return(View(dbProduct.GetAllProducts())); }
public void When_Saving_A_Product_Index_View_Should_be_Returned_With_The_New_Product_List() { //Arrange var controller = new ProductsController(); var product = new Product { Name = "dummy", Cost = 20 }; //Act var existingCount = ProductsDb.GetAllProducts().Count(); var result = controller.Save(product); //Assert Assert.IsTrue(ProductsDb.GetAllProducts().Count() == existingCount + 1); Assert.IsTrue(((RedirectToRouteResult)result).RouteValues["action"].ToString() == "Index"); }
// // GET: /Products/ public ViewResult Index() { return(View("Index", ProductsDb.GetAllProducts())); }
// GET: User public async Task <IActionResult> Index(int?id) { List <Product> products = await ProductsDb.GetAllProducts(_context); return(View(products)); }