public void EditEmp(Employee emp) { var selectedEmp = empContext.Employee.Where(x => x.EmpID == emp.EmpID).SingleOrDefault(); selectedEmp.FirstName = emp.FirstName; selectedEmp.LastName = emp.LastName; selectedEmp.DeptID = emp.DeptID; empContext.SaveChanges(); }
public ActionResult Update(Employee model) { if (ModelState.IsValid) { emp.EditEmp(model); return RedirectToAction("Index"); } return View(model); }
public ActionResult Create(Employee model) { if (ModelState.IsValid) { emp.SaveEmp(model); return RedirectToAction("Index"); } return View(); }
public void SaveEmp(Employee emp) { empContext.Employee.Add(emp); empContext.SaveChanges(); }
public ActionResult Details(Employee model) { return View(model); }
public ActionResult Create() { Employee model = new Employee(); return View(model); }