public ActionResult Delete(Employee emp) { using (EMPcontext context = new EMPcontext()) { Employee employee = context.Employees.Where(x => x.Id == emp.Id).SingleOrDefault(); context.Employees.Remove(employee); context.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Create(Employee model) { using (EMPcontext context = new EMPcontext()) { context.Employees.Add(model); context.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Edit(Employee model) { using (EMPcontext context = new EMPcontext()) { Employee employee = context.Employees.Where(x => x.Id == model.Id).SingleOrDefault(); employee.FirstName = model.FirstName; employee.LastName = model.LastName; employee.PhoneNumber = model.PhoneNumber; employee.EmailAddress = model.EmailAddress; context.SaveChanges(); } return(RedirectToAction("Index")); }