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