コード例 #1
0
 public ActionResult Edit(Category category)
 {
     if (ModelState.IsValid)
     {
         context.Entry(category).State = EntityState.Modified;
         context.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(category);
 }
コード例 #2
0
        public ActionResult Create(Category category)
        {
            if (ModelState.IsValid)
            {
                context.Categories.Add(category);
                context.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(category);
        }