示例#1
0
 public IActionResult AddProduct(Product product)
 {
     if (ModelState.IsValid)
     {
         try
         {
             creatable.Add(product);
             return(RedirectToAction("Index"));
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("", ex.Message);
             return(View(product));
         }
     }
     return(View(product));
 }
示例#2
0
 public IActionResult AddOrder(Order order)
 {
     if (ModelState.IsValid)
     {
         try
         {
             creatable.Add(order);
             return(RedirectToAction("Index"));
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("", ex.Message);
             return(View(order));
         }
     }
     return(View(order));
 }