public ProductsAndListProducts ListOfProductsViewModel() { ProductsAndListProducts LOP = new ProductsAndListProducts(); LOP.ListOfProducts = dbContext.Products.ToList(); return(LOP); }
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)); }
public ViewResult Index() { ProductsAndListProducts viewModel = ListOfProductsViewModel(); return(View("Index", viewModel)); }