public ActionResult Create(Student student) { if (ModelState.IsValid) { try { db.Studentdbs.Add(student); db.SaveChanges(); return RedirectToAction("Index"); } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } ModelState.AddModelError("", ex.Message); } } return View(student); }
public ActionResult Edit(Student student) { if (ModelState.IsValid) { db.Entry(student).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(student); }