public JsonResult Edit(DepartmentDto model) { string errs = GetModelStateError(); if (!string.IsNullOrEmpty(errs)) { return(Json(new OperateMessage <string>(OperateResult.Fail, true, errs))); } DepartmentDto currModel = _DepartmentAppService.Get(model.ID); if (currModel == null) { return(Json(new OperateMessage <string>(OperateResult.Fail, true, "修改失败,修改的内容不存在!"))); } currModel.Code = model.Code; currModel.ContactNumber = model.ContactNumber; currModel.IsDeleted = model.IsDeleted; currModel.LastUpdateTime = DateTime.Now; currModel.LastUpdateUserID = _currUser.ID; currModel.Manager = model.Manager; currModel.Name = model.Name; currModel.ParentId = model.ParentId; currModel.Remarks = model.Remarks; bool IsSucceed = _DepartmentAppService.Edit(currModel); if (IsSucceed) { return(Json(new OperateMessage <string>("/Department/Index"))); } return(Json(new OperateMessage <string>(IsSucceed ? OperateResult.Success : OperateResult.Fail, true, IsSucceed ? "修改成功!" : "修改失败!"))); }
/// <summary> /// 新增或编辑功能 /// </summary> /// <param name="dto"></param> /// <returns></returns> public IActionResult Edit(DepartmentDto dto) { if (!ModelState.IsValid) { return(Json(new { Result = "Faild", Message = GetModelStateError() })); } if (dto.ID != Guid.Empty ? _service.Edit(dto) : _service.Create(dto)) { return(Json(new { Result = "Success" })); } return(Json(new { Result = "Faild" })); }