public ActionResult Edit(int id) { EmployeeContext employeeContext = new EmployeeContext(); Employee employee = employeeContext.Employees.Find(id); return View(employee); }
// GET: Employee public ActionResult Index() { EmployeeContext employeeContext = new EmployeeContext(); List<Employee> employees = employeeContext.Employees.ToList(); return View(employees); }
public ActionResult DeleteConfirmed(int id) { EmployeeContext employeeContext = new EmployeeContext(); Employee employee = employeeContext.Employees.Find(id); employeeContext.Employees.Remove(employee); employeeContext.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult Edit(Employee employee) { EmployeeContext employeeContext = new EmployeeContext(); employeeContext.Entry(employee).State = System.Data.Entity.EntityState.Modified; employeeContext.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult Create(Employee employee) { EmployeeContext employeeContext = new EmployeeContext(); employeeContext.Employees.Add(employee); employeeContext.SaveChanges(); return RedirectToAction("Index"); }