コード例 #1
0
        public ActionResult Stock()
        {
            ProductsDb dbProduct = new ProductsDb();

            ModelState.Clear();
            return(View(dbProduct.GetAllProducts()));
        }
コード例 #2
0
        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");
        }
コード例 #3
0
        //
        // GET: /Products/

        public ViewResult Index()
        {
            return(View("Index", ProductsDb.GetAllProducts()));
        }
コード例 #4
0
        // GET: User
        public async Task <IActionResult> Index(int?id)
        {
            List <Product> products = await ProductsDb.GetAllProducts(_context);

            return(View(products));
        }