public ActionResult AddEmployee([DataSourceRequest] DataSourceRequest request, EmployeeModel employeeModel) { try { if (employeeModel != null) { this.systemEmployeeService = new SystemEmployeeService(); var backstageEmployee = DataTransfer.Transfer<System_Employee>( employeeModel, typeof(EmployeeModel)); employeeModel.ID = this.systemEmployeeService.AddEmployee(backstageEmployee); if (employeeModel.ID > 0) { return this.Json(new[] { employeeModel }.ToDataSourceResult(request, this.ModelState)); } } } catch (Exception exception) { throw new Exception("添加员工时发生错误", exception); } return this.View(); }
public ActionResult ModifyEmployee([DataSourceRequest] DataSourceRequest request, EmployeeModel employeeModel) { if (employeeModel != null && this.ModelState.IsValid) { this.systemEmployeeService = new SystemEmployeeService(); var backstageEmployee = DataTransfer.Transfer<System_Employee>( employeeModel, typeof(EmployeeModel)); this.systemEmployeeService.ModifyEmployee(backstageEmployee); } return this.Json(new[] { employeeModel }.ToDataSourceResult(request, this.ModelState)); }