| | | 1 | | using Elsa.Authorization; |
| | | 2 | | using Elsa.Abstractions; |
| | | 3 | | using Elsa.Workflows.Api.Constants; |
| | | 4 | | using Elsa.Workflows.Api.Requirements; |
| | | 5 | | using Elsa.Workflows.Management; |
| | | 6 | | using JetBrains.Annotations; |
| | | 7 | | using Microsoft.AspNetCore.Authorization; |
| | | 8 | | |
| | | 9 | | namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.DeleteVersion; |
| | | 10 | | |
| | | 11 | | [PublicAPI] |
| | 3 | 12 | | internal class DeleteVersion(IWorkflowDefinitionManager workflowDefinitionManager, IAuthorizationService authorizationSe |
| | | 13 | | : ElsaEndpoint<Request> |
| | | 14 | | { |
| | | 15 | | public override void Configure() |
| | | 16 | | { |
| | 3 | 17 | | Delete("/workflow-definition-versions/{id}"); |
| | 3 | 18 | | RequirePermission(Elsa.Workflows.Api.Permissions.WorkflowPermissions.Definitions, CoreVerbs.Delete); |
| | 3 | 19 | | } |
| | | 20 | | |
| | | 21 | | public override async Task HandleAsync(Request request, CancellationToken cancellationToken) |
| | | 22 | | { |
| | 0 | 23 | | var authorizationResult = await authorizationService.AuthorizeAsync(User, new NotReadOnlyResource(), Authorizati |
| | | 24 | | |
| | 0 | 25 | | if (!authorizationResult.Succeeded) |
| | | 26 | | { |
| | 0 | 27 | | await Send.ForbiddenAsync(cancellationToken); |
| | 0 | 28 | | return; |
| | | 29 | | } |
| | | 30 | | |
| | 0 | 31 | | var deleted = await workflowDefinitionManager.DeleteByIdAsync(request.Id, cancellationToken); |
| | | 32 | | |
| | 0 | 33 | | if (!deleted) |
| | 0 | 34 | | await Send.NotFoundAsync(cancellationToken); |
| | | 35 | | else |
| | 0 | 36 | | await Send.NoContentAsync(cancellationToken); |
| | 0 | 37 | | } |
| | | 38 | | } |