| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Workflows.Api.Models; |
| | | 3 | | using Elsa.Workflows.Management; |
| | | 4 | | using Elsa.Workflows.Management.Filters; |
| | | 5 | | using JetBrains.Annotations; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Workflows.Api.Endpoints.WorkflowInstances.Get; |
| | | 8 | | |
| | | 9 | | [PublicAPI] |
| | 1 | 10 | | internal class Get(IWorkflowInstanceStore store) : ElsaEndpoint<Request, WorkflowInstanceModel, WorkflowInstanceMapper> |
| | | 11 | | { |
| | | 12 | | public override void Configure() |
| | | 13 | | { |
| | 1 | 14 | | Get("/workflow-instances/{id}"); |
| | 1 | 15 | | ConfigurePermissions("read:workflow-instances"); |
| | 1 | 16 | | } |
| | | 17 | | |
| | | 18 | | public override async Task HandleAsync(Request request, CancellationToken cancellationToken) |
| | | 19 | | { |
| | 0 | 20 | | var filter = new WorkflowInstanceFilter { Id = request.Id }; |
| | 0 | 21 | | var workflowInstance = await store.FindAsync(filter, cancellationToken); |
| | | 22 | | |
| | 0 | 23 | | if (workflowInstance == null) |
| | 0 | 24 | | await Send.NotFoundAsync(cancellationToken); |
| | | 25 | | else |
| | 0 | 26 | | await Send.OkAsync(Map.FromEntity(workflowInstance), cancellationToken); |
| | 0 | 27 | | } |
| | | 28 | | } |