/// <summary> /// 保存操作功能 /// </summary> /// <param name="saveOperationDto">操作功能保存信息</param> /// <returns>执行结果</returns> public Result <OperationDto> SaveOperation(SaveOperationDto saveOperationDto) { if (saveOperationDto == null) { return(Result <OperationDto> .FailedResult("操作功能信息不完整")); } using (var businessWork = WorkManager.Create()) { var saveResult = operationService.Save(saveOperationDto.Operation.MapTo <Operation>()); if (!saveResult.Success) { return(Result <OperationDto> .FailedResult(saveResult.Message)); } var commitResult = businessWork.Commit(); Result <OperationDto> result = null; if (commitResult.EmptyResultOrSuccess) { result = Result <OperationDto> .SuccessResult("保存成功"); result.Data = saveResult.Data.MapTo <OperationDto>(); } else { result = Result <OperationDto> .SuccessResult("保存失败"); } return(result); } }
public ActionResult EditOperation(OperationViewModel operation, long groupId = 0) { if (IsPost) { SaveOperationDto saveInfo = new SaveOperationDto() { Operation = operation.MapTo <OperationDto>() }; Result <OperationDto> result = operationAppService.SaveOperation(saveInfo); var ajaxResult = AjaxResult.CopyFromResult(result); ajaxResult.SuccessClose = true; return(Json(ajaxResult)); } else { if (operation.Id > 0) { OperationFilterDto filter = new OperationFilterDto() { Ids = new List <long>() { operation.Id }, LoadGroup = true }; operation = operationAppService.GetOperation(filter).MapTo <OperationViewModel>(); if (operation == null) { return(Content("没有指定要操作的数据")); } } else if (groupId > 0) { operation.Group = operationGroupAppService.GetOperationGroup(new OperationGroupFilterDto() { Ids = new List <long>() { groupId } })?.MapTo <OperationGroupViewModel>(); } } return(View(operation)); }
/// <summary> /// 保存操作功能 /// </summary> /// <param name="saveOperationDto">操作功能保存信息</param> /// <returns>返回执行结果</returns> public Result <OperationDto> SaveOperation(SaveOperationDto saveOperationDto) { return(operationBusiness.SaveOperation(saveOperationDto)); }