public void UpdateDepartment(EditDepartmentModel model) { if (!model.Id.HasValue) throw new ArgumentException("model.id不能为null"); var department = _departmentRepository.Find(model.Id.Value); department.Name = model.FormData.Name; department.Unit = NpcContext.CurrentUser.Unit; department.RecordDescription.UpdateBy(NpcContext.CurrentUser); _departmentRepository.Save(department); }
public void CreateNewDepartment(EditDepartmentModel model) { var department = new Department(); department.Name = model.FormData.Name; department.Unit = NpcContext.CurrentUser.Unit; if (model.ParentId.HasValue) department.Parent = _departmentRepository.Find(model.ParentId.Value); department.RecordDescription.CreateBy(NpcContext.CurrentUser); _departmentRepository.Save(department); }
public JsonResult EditUnitPost(EditDepartmentModel model) { try { _departmentAction.CreateNewDepartment(model); } catch (Exception) { return new NewtonsoftJsonResult() { Data = new { status = "failure" } }; } return new NewtonsoftJsonResult() { Data = new { status = "success" } }; }