public ActionResult Update_Employee(EmployeeViewModel employee) { if (employee != null && ModelState.IsValid) { var target = GetEmployeeByID(employee.EmployeeID); target.FirstName = employee.FirstName; target.LastName = employee.LastName; target.Title = employee.Title; target.Country = employee.Country; target.City = employee.City; context.SaveChanges(); } return Json(ModelState.ToDataSourceResult()); }
public ActionResult Create_Employee(EmployeeViewModel employee) { if (employee != null && ModelState.IsValid) { var target = new Employee(); target.FirstName = employee.FirstName; target.LastName = employee.LastName; target.Title = employee.Title; target.Country = employee.Country; target.City = employee.City; context.Employees.AddObject(target); context.SaveChanges(); employee.EmployeeID = target.EmployeeID; } return Json(new[] { employee }.ToDataSourceResult(new DataSourceRequest(), ModelState)); }