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)); }
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())); }