< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.DeleteVersion.DeleteVersion
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/DeleteVersion/Endpoint.cs
Line coverage
30%
Covered lines: 4
Uncovered lines: 9
Coverable lines: 13
Total lines: 37
Line coverage: 30.7%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Configure()100%11100%
HandleAsync()0%2040%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/DeleteVersion/Endpoint.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Workflows.Api.Constants;
 3using Elsa.Workflows.Api.Requirements;
 4using Elsa.Workflows.Management;
 5using JetBrains.Annotations;
 6using Microsoft.AspNetCore.Authorization;
 7
 8namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.DeleteVersion;
 9
 10[PublicAPI]
 111internal class DeleteVersion(IWorkflowDefinitionManager workflowDefinitionManager, IAuthorizationService authorizationSe
 12    : ElsaEndpoint<Request>
 13{
 14    public override void Configure()
 15    {
 116        Delete("/workflow-definition-versions/{id}");
 117        ConfigurePermissions("delete:workflow-definitions");
 118    }
 19
 20    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 21    {
 022        var authorizationResult = await authorizationService.AuthorizeAsync(User, new NotReadOnlyResource(), Authorizati
 23
 024        if (!authorizationResult.Succeeded)
 25        {
 026            await Send.ForbiddenAsync(cancellationToken);
 027            return;
 28        }
 29
 030        var deleted = await workflowDefinitionManager.DeleteByIdAsync(request.Id, cancellationToken);
 31
 032        if (!deleted)
 033            await Send.NotFoundAsync(cancellationToken);
 34        else
 035            await Send.NoContentAsync(cancellationToken);
 036    }
 37}