public ActionResult Edit(int id, EmployeeInfo Emp) { try { var ep = ctx.EmployeeInfoes.Find(id); if (ep != null) { ep.EmpName = Emp.EmpName; ep.DeptName = Emp.DeptName; if (Emp.Salary < 1000) { throw new Exception(); } ep.Salary = Emp.Salary; ep.Designation = Emp.Designation; ctx.SaveChanges(); } return RedirectToAction("Index"); } catch (Exception ex) { //Method 1 //return View("Error",new HandleErrorInfo(ex,"EmployeeInfo","Create")); //Method 2 throw ex; } }
public ActionResult Create(EmployeeInfo Emp) { try { ctx.EmployeeInfoes.Add(Emp); ctx.SaveChanges(); return RedirectToAction("Index"); } catch(Exception ex) { //Method 1 // return View("Error",new HandleErrorInfo(ex,"EmployeeInfo","Create")); //Method 2 throw ex; } }
// GET: EmployeeInfo/Create public ActionResult Create() { var Emp = new EmployeeInfo(); return View(Emp); }