コード例 #1
0
 public ActionResult Edit(Category category)
 {
     if (ModelState.IsValid)
     {
         using (var ctx = new ShoppingStoreDB())
         {
             if (category.Id_Category > 0)
             {
                 ctx.UpdateCategory(category);
             }
             else
             {
                 ctx.Categories.Add(category);
                 ctx.SaveChanges();
             }
         }
     }
     return(RedirectToAction("Categories"));
 }