| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Workflows.Api.Constants; |
| | | 3 | | using JetBrains.Annotations; |
| | | 4 | | using Microsoft.AspNetCore.Authorization; |
| | | 5 | | using Elsa.Workflows.Api.Requirements; |
| | | 6 | | using Elsa.Workflows.Management; |
| | | 7 | | |
| | | 8 | | namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.BulkDelete; |
| | | 9 | | |
| | | 10 | | [UsedImplicitly] |
| | 1 | 11 | | internal class BulkDelete(IWorkflowDefinitionManager workflowDefinitionManager, IAuthorizationService authorizationServi |
| | | 12 | | : ElsaEndpoint<Request, Response> |
| | | 13 | | { |
| | | 14 | | public override void Configure() |
| | | 15 | | { |
| | 1 | 16 | | Post("/bulk-actions/delete/workflow-definitions/by-definition-id"); |
| | 1 | 17 | | ConfigurePermissions("delete:workflow-definitions"); |
| | 1 | 18 | | } |
| | | 19 | | |
| | | 20 | | public override async Task<Response> ExecuteAsync(Request request, CancellationToken cancellationToken) |
| | | 21 | | { |
| | 0 | 22 | | var authorizationResult = await authorizationService.AuthorizeAsync(User, new NotReadOnlyResource(), Authorizati |
| | | 23 | | |
| | 0 | 24 | | if (!authorizationResult.Succeeded) |
| | | 25 | | { |
| | 0 | 26 | | await Send.ForbiddenAsync(cancellationToken); |
| | 0 | 27 | | return null!; |
| | | 28 | | } |
| | | 29 | | |
| | 0 | 30 | | var count = await workflowDefinitionManager.BulkDeleteByDefinitionIdsAsync(request.DefinitionIds, cancellationTo |
| | 0 | 31 | | return new Response(count); |
| | 0 | 32 | | } |
| | | 33 | | } |