예제 #1
0
        public JsonResult Update([DataSourceRequest] DataSourceRequest request, EmployeeDirectoryModel employee)
        {
            if (ModelState.IsValid)
            {
                employeeDirectory.Update(employee, ModelState);
            }

            return(Json(new[] { employee }.ToTreeDataSourceResult(request, ModelState)));
        }
예제 #2
0
        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)));
        }
예제 #3
0
        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)));
        }
예제 #4
0
        public JsonResult OnPostCreate([DataSourceRequest] DataSourceRequest request, EmployeeDirectoryModel employee)
        {
            employee.EmployeeId = employees.Count + 2;
            employees.Add(employee);

            return(new JsonResult(new[] { employee }.ToTreeDataSourceResult(request, ModelState)));
        }