public JsonResult Update([DataSourceRequest] DataSourceRequest request, EmployeeDirectoryModel employee) { if (ModelState.IsValid) { employeeDirectory.Update(employee, ModelState); } return(Json(new[] { employee }.ToTreeDataSourceResult(request, ModelState))); }
public JsonResult OnPostUpdate([DataSourceRequest] DataSourceRequest request, EmployeeDirectoryModel employee) { var target = employees.FirstOrDefault(x => x.EmployeeId == employee.EmployeeId); if (target != null) { target.FirstName = employee.FirstName; target.LastName = employee.LastName; target.HireDate = employee.HireDate; target.Position = employee.Position; target.ReportsTo = employee.ReportsTo; } return(new JsonResult(new[] { employee }.ToTreeDataSourceResult(request, ModelState))); }
public JsonResult OnPostDestroy([DataSourceRequest] DataSourceRequest request, EmployeeDirectoryModel employee) { employees.Remove(employees.FirstOrDefault(x => x.EmployeeId == employee.EmployeeId)); return(new JsonResult(new[] { employee }.ToTreeDataSourceResult(request, ModelState))); }
public JsonResult OnPostCreate([DataSourceRequest] DataSourceRequest request, EmployeeDirectoryModel employee) { employee.EmployeeId = employees.Count + 2; employees.Add(employee); return(new JsonResult(new[] { employee }.ToTreeDataSourceResult(request, ModelState))); }