Пример #1
0
 public IActionResult CreateProduct(Product product)
 {
     if (ModelState.IsValid)
     {
         dbContext.Add(product);
         dbContext.SaveChanges();
         return(RedirectToAction("CreateProduct"));
     }
     else
     {
         List <Product> ProductList = dbContext.products.ToList();
         ViewBag.ProductList = ProductList;
         return(View("CreateProduct"));
     }
 }
Пример #2
0
 public void saveProduct(Product p)
 {
     context.products.Add(p);
     context.SaveChanges();
     return;
 }