public ActionResult Delete(string id) { int empId = int.Parse(id); var context = new Mydatabase(); var model = context.Employees.FirstOrDefault((e) => e.EmpID == empId); context.Employees.Remove(model); context.SaveChanges(); return(RedirectToAction("AllEmployees")); }
public ActionResult Find(Employee emp) { var context = new Mydatabase(); var model = context.Employees.FirstOrDefault((e) => e.EmpID == emp.EmpID); model.EmpName = emp.EmpName; model.EmpAddress = emp.EmpAddress; model.EmpSalary = emp.EmpSalary; context.SaveChanges(); return(RedirectToAction("AllEmployees")); }
public ActionResult NewEmployee(Employee emp) { try { var context = new Mydatabase(); context.Employees.Add(emp); context.SaveChanges(); return(RedirectToAction("AllEmployees")); } catch { return(RedirectToAction("AllEmployees")); } }