| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Common.Models; |
| | | 3 | | using Elsa.Workflows.Management; |
| | | 4 | | using Elsa.Workflows.Models; |
| | | 5 | | using JetBrains.Annotations; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.GetByDefinitionId; |
| | | 8 | | |
| | | 9 | | [PublicAPI] |
| | 1 | 10 | | internal class GetByDefinitionId(IWorkflowDefinitionStore store, IWorkflowDefinitionLinker linker) : ElsaEndpoint<Reques |
| | | 11 | | { |
| | | 12 | | public override void Configure() |
| | | 13 | | { |
| | 1 | 14 | | Get("/workflow-definitions/by-definition-id/{definitionId}", "/workflow-definitions/{definitionId}"); |
| | 1 | 15 | | ConfigurePermissions("read:workflow-definitions"); |
| | 1 | 16 | | } |
| | | 17 | | |
| | | 18 | | public override async Task HandleAsync(Request request, CancellationToken cancellationToken) |
| | | 19 | | { |
| | 0 | 20 | | var versionOptions = request.VersionOptions != null ? VersionOptions.FromString(request.VersionOptions) : Versio |
| | 0 | 21 | | var filter = WorkflowDefinitionHandle.ByDefinitionId(request.DefinitionId, versionOptions).ToFilter(); |
| | 0 | 22 | | var definition = await store.FindAsync(filter, cancellationToken); |
| | | 23 | | |
| | 0 | 24 | | if (definition == null) |
| | | 25 | | { |
| | 0 | 26 | | await Send.NotFoundAsync(cancellationToken); |
| | 0 | 27 | | return; |
| | | 28 | | } |
| | | 29 | | |
| | 0 | 30 | | var model = await linker.MapAsync(definition, cancellationToken); |
| | 0 | 31 | | await Send.OkAsync(model, cancellationToken); |
| | 0 | 32 | | } |
| | | 33 | | } |