public ActionResult Create(ConTent content) { if (ModelState.IsValid) { var dao = new ConTentDao(); long id = dao.Insert(content); if (id > 0) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Thêm mới thất bại"); } } SetViewBag(); return(View()); }
public long Insert(ConTent entity) { db.ConTents.Add(entity); db.SaveChanges(); return(entity.ID); }