public ActionResult Create(OffenceType offencetype) { if (ModelState.IsValid) { Db.OffenceTypes.Add(offencetype); Db.SaveChanges(); return RedirectToAction("Index"); } return View(offencetype); }
public ActionResult Edit(OffenceType offencetype) { if (ModelState.IsValid) { Db.Entry(offencetype).State = EntityState.Modified; Db.SaveChanges(); return RedirectToAction("Index"); } return View(offencetype); }
public ActionResult GetOffenceTypeAndAll() { var list = Db.OffenceTypes.ToList(); var all = new OffenceType() { Id = 0, Name = "全部" }; list.Insert(0, all); return Json(list); }