예제 #1
0
파일: Post.cs 프로젝트: mhymhygi/elsa-core
        public async Task <ActionResult <WorkflowSetting> > Handle([FromBody] SaveWorkflowSettingRequest request, [FromRoute] ApiVersion apiVersion, CancellationToken cancellationToken)
        {
            var workflowSettingsId  = request.Id;
            var workflowBlueprintId = request.WorkflowBlueprintId;
            var key = request.Key;

            var workflowSettings = !string.IsNullOrWhiteSpace(workflowSettingsId)
                ? await _workflowSettingsStore.FindByWorkflowBlueprintIdAndKeyAsync(workflowBlueprintId, key, cancellationToken)
                : default;

            if (workflowSettings == null)
            {
                workflowSettings = new WorkflowSetting
                {
                    Id = !string.IsNullOrWhiteSpace(workflowSettingsId) ? workflowSettingsId : _idGenerator.Generate(),
                };
            }

            workflowSettings.WorkflowBlueprintId = request.WorkflowBlueprintId.Trim();
            workflowSettings.Key   = request.Key.Trim();
            workflowSettings.Value = request.Value?.Trim();

            await _workflowSettingsStore.SaveAsync(workflowSettings, cancellationToken);

            return(CreatedAtAction("Handle", "Get", new { id = workflowSettings.Id, apiVersion = apiVersion.ToString() }, workflowSettings));
        }
예제 #2
0
        public override async ValueTask <WorkflowSetting> GetWorkflowSettingAsync(string workflowBlueprintId, string key, CancellationToken cancellationToken)
        {
            var workflowSettings = await _workflowSettingsStore.FindByWorkflowBlueprintIdAndKeyAsync(workflowBlueprintId, key, cancellationToken);

            if (workflowSettings != null && workflowSettings.Value != null)
            {
                return(await new ValueTask <WorkflowSetting>(new WorkflowSetting {
                    Value = workflowSettings.Value
                }));
            }

            return(await new ValueTask <WorkflowSetting>(new WorkflowSetting()));
        }