Exemple #1
0
        public ProductsAndListProducts ListOfProductsViewModel()
        {
            ProductsAndListProducts LOP = new ProductsAndListProducts();

            LOP.ListOfProducts = dbContext.Products.ToList();
            return(LOP);
        }
Exemple #2
0
        public IActionResult CreateProduct(ProductsAndListProducts newPro)
        {
            if (ModelState.IsValid)
            {
                dbContext.Add(newPro.NewProduct);
                dbContext.SaveChanges();
                return(RedirectToAction("Index")); //CHANGE LATER TO REDIRECT TO PRODUCT ID PAGE
            }
            ProductsAndListProducts viewModel = ListOfProductsViewModel();

            return(View("Index", viewModel));
        }
Exemple #3
0
        public ViewResult Index()
        {
            ProductsAndListProducts viewModel = ListOfProductsViewModel();

            return(View("Index", viewModel));
        }