public ActionResult Edit(Employee employee) { try { if (ModelState.IsValid) { db.Entry(employee).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); // update return RedirectToAction("Index"); } } catch { throw new Exception("We can't save the modified data."); } return View(employee); }
public ActionResult Create(Employee employee) { try { if (ModelState.IsValid) { db.Employees.Add(employee); db.SaveChanges();// insert into return RedirectToAction("Index"); } } catch { throw new Exception("We can't create data."); } return RedirectToAction("Index"); }