| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Models; |
| | | 3 | | using Elsa.Workflows.Api.Models; |
| | | 4 | | using Elsa.Workflows.Management; |
| | | 5 | | using Elsa.Workflows.Management.Filters; |
| | | 6 | | using JetBrains.Annotations; |
| | | 7 | | |
| | | 8 | | namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.GetManyById; |
| | | 9 | | |
| | | 10 | | [PublicAPI] |
| | 1 | 11 | | internal class GetManyById(IWorkflowDefinitionStore store, IWorkflowDefinitionLinker linker) : ElsaEndpoint<Request> |
| | | 12 | | { |
| | | 13 | | public override void Configure() |
| | | 14 | | { |
| | 1 | 15 | | Get("/workflow-definitions/many-by-id"); |
| | 1 | 16 | | ConfigurePermissions("read:workflow-definitions"); |
| | 1 | 17 | | } |
| | | 18 | | |
| | | 19 | | public override async Task HandleAsync(Request request, CancellationToken cancellationToken) |
| | | 20 | | { |
| | 0 | 21 | | var filter = new WorkflowDefinitionFilter |
| | 0 | 22 | | { |
| | 0 | 23 | | Ids = request.Ids |
| | 0 | 24 | | }; |
| | | 25 | | |
| | 0 | 26 | | var definitions = (await store.FindManyAsync(filter, cancellationToken)).ToList(); |
| | 0 | 27 | | var models = await linker.MapAsync(definitions, cancellationToken); |
| | 0 | 28 | | var response = new ListResponse<LinkedWorkflowDefinitionModel>(models); |
| | 0 | 29 | | await Send.OkAsync(response, cancellationToken); |
| | 0 | 30 | | } |
| | | 31 | | } |