public async Task <IActionResult> AddOrUpdate(WorkFlowFlowViewModel viewModel) { var isSuccess = await _workFlowFlowService.AddOrUpdateWorkFlowFlow(viewModel); if (!isSuccess) { return(this.BadRequestResult("操作失败!")); } return(Ok()); }
public async Task <bool> AddOrUpdateWorkFlowFlow(WorkFlowFlowViewModel viewModel) { try { var userName = _httpContextAccessor.HttpContext?.User?.GetUserName(); foreach (var link in viewModel.WorkFlowLinkViewModels) { link.WorkFlowId = viewModel.WorkFlowId; } foreach (var node in viewModel.WorkFlowNodeViewModels) { node.WorkFlowId = viewModel.WorkFlowId; } foreach (var condition in viewModel.WorkFlowConditionViewModels) { condition.WorkFlowId = viewModel.WorkFlowId; } var workflow = await _workflowRepository.GetAsync(viewModel.WorkFlowId); workflow.UpdatedTime = DateTime.Now; workflow.UpdatedUser = userName; await _linkRepository.RemoveAsync(f => f.WorkFlowId == viewModel.WorkFlowId); await _linkRepository.AddAsync(_mapper.Map <IEnumerable <WorkFlowLink> >(viewModel.WorkFlowLinkViewModels)); await _nodeRepository.RemoveAsync(f => f.WorkFlowId == viewModel.WorkFlowId); await _nodeRepository.AddAsync(_mapper.Map <IEnumerable <WorkFlowNode> >(viewModel.WorkFlowNodeViewModels)); await _conditionRepository.RemoveAsync(f => f.WorkFlowId == viewModel.WorkFlowId); await _conditionRepository.AddAsync(_mapper.Map <IEnumerable <WorkFlowCondition> >(viewModel.WorkFlowConditionViewModels)); await _unitOfWork.SaveAsync(); return(true); } catch (Exception e) { _logger.LogError(e.StackTrace); return(false); } }
public async Task <IActionResult> AddOrUpdateWorkFlowFlowNode([FromBody] WorkFlowFlowViewModel model) { await _workFlowFlowService.AddOrUpdateFlow(model.DefineId, model.Nodes, model.Connections, model.NodeElements); return(Ok()); }