コード例 #1
0
        public ActionResult Create(Category category)
        {
            if (ModelState.IsValid)
            {
                db.Category.Add(category);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.ParentID = new SelectList(db.Category, "CategoryID", "CategoryName", category.ParentID);
            return View(category);
        }
コード例 #2
0
 public ActionResult Edit(Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.ParentID = new SelectList(db.Category, "CategoryID", "CategoryName", category.ParentID);
     return View(category);
 }