public JsonResult Create(Employee emp) { using (EmployeeListEntities entities = new EmployeeListEntities()) { entities.Employees.Add(emp); entities.SaveChanges(); } return(Json(emp)); }
public ActionResult DeleteEmployee(int employeeId) { using (EmployeeListEntities entities = new EmployeeListEntities()) { Employee employeeList = (from c in entities.Employees where c.EmployeeId == employeeId select c).FirstOrDefault(); entities.Employees.Remove(employeeList); entities.SaveChanges(); } return(new EmptyResult()); }
public ActionResult UpdateEmployee(Employee emp) { using (EmployeeListEntities entities = new EmployeeListEntities()) { Employee updatedList = (from c in entities.Employees where c.EmployeeId == emp.EmployeeId select c).FirstOrDefault(); updatedList.EmployeeName = emp.EmployeeName; updatedList.DesignationId = emp.DesignationId; updatedList.Gender = emp.Gender; updatedList.DOB = emp.DOB; updatedList.EmailId = emp.EmailId; updatedList.MobileNo = emp.MobileNo; updatedList.Address = emp.Address; updatedList.Description = emp.Description; updatedList.Salary = emp.Salary; entities.SaveChanges(); } return(new EmptyResult()); }
// GET: Employee public ActionResult Index() { EmployeeListEntities entities = new EmployeeListEntities(); return(View(entities.Employees)); }