public IHttpActionResult UpdateEmployee(int id, [FromBody] Employee e) { EmployeeBll.UpdateEmployee(id, e); return(Ok()); }
public ActionResult AddOrUpdateEmployee(EmployeeViewModel employeeViewModel) { bool result = false; var msg = ""; try { #region Bas_Employee Bas_Employee bas_Employee = null; if (employeeViewModel.Id > 0) { bas_Employee = employeeBll.GetEmployeeEntity(employeeViewModel.Id); if (bas_Employee == null) { throw new AbhsException(ErrorCodeEnum.ParameterInvalid, AbhsErrorMsg.ConstParameterInvalid); } } if (bas_Employee == null) { bas_Employee = new Bas_Employee(); } bas_Employee.Bem_Id = employeeViewModel.Id; bas_Employee.Bem_Account = employeeViewModel.Account; if (employeeViewModel.Password.HasValue()) { bas_Employee.Bem_Password = Encrypt.GetMD5Pwd(employeeViewModel.Password); } bas_Employee.Bem_Name = employeeViewModel.Name; bas_Employee.Bem_Sex = employeeViewModel.Sex; bas_Employee.Bem_Phone = employeeViewModel.Phone; bas_Employee.Bem_Email = employeeViewModel.Email; bas_Employee.Bem_Roles = employeeViewModel.Roles; bas_Employee.Bem_Status = employeeViewModel.Status; bas_Employee.Bem_Remark = employeeViewModel.Remark; bas_Employee.Bem_Grades = employeeViewModel.Grades.Sum(); #endregion Bas_EmployeeRole bas_EmployeeRole = new Bas_EmployeeRole(); if (bas_Employee.Bem_Id == 0) { bas_Employee.Bem_CreateTime = DateTime.Now; bas_Employee.Bem_Editor = CurrentUserID; bas_Employee.Bem_LastLoginTime = DateTimeExtensions.DefaultDateTime; bas_EmployeeRole.Ber_CreateTime = DateTime.Now; bas_EmployeeRole.Ber_Creator = CurrentUserID; result = employeeBll.AddEmployee(bas_Employee, bas_EmployeeRole); } else { bas_Employee.Bem_UpdateTime = DateTime.Now; bas_Employee.Bem_Editor = CurrentUserID; bas_EmployeeRole.Ber_CreateTime = DateTime.Now; bas_EmployeeRole.Ber_Creator = CurrentUserID; result = employeeBll.UpdateEmployee(bas_Employee, bas_EmployeeRole); } } catch (Exception ex) { msg = "异常,请重试"; //return Json(new JsonSimpleResponse() { State = false, ErrorMsg = ex.Message }); } msg = result ? "操作成功" : "操作失败"; return(Json(new JsonSimpleResponse() { State = result, ErrorMsg = msg })); }