public ActionResult Create(int id) { ViewBag.viewID = id; Category category = new Category(); category.parentID = id; category.sortNum = db.Category.Where(x => x.parentID == id).Count() + 1; return View(category); }
public ActionResult Create(Category category) { if (ModelState.IsValid) { db.Category.Add(category); db.SaveChanges(); return RedirectToAction("CategorySpryList", new { id = category.parentID }); } return View(category); }