< 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: 38
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.Authorization;
 2using Elsa.Abstractions;
 3using Elsa.Workflows.Api.Constants;
 4using Elsa.Workflows.Api.Requirements;
 5using Elsa.Workflows.Management;
 6using JetBrains.Annotations;
 7using Microsoft.AspNetCore.Authorization;
 8
 9namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.DeleteVersion;
 10
 11[PublicAPI]
 312internal class DeleteVersion(IWorkflowDefinitionManager workflowDefinitionManager, IAuthorizationService authorizationSe
 13    : ElsaEndpoint<Request>
 14{
 15    public override void Configure()
 16    {
 317        Delete("/workflow-definition-versions/{id}");
 318        RequirePermission(Elsa.Workflows.Api.Permissions.WorkflowPermissions.Definitions, CoreVerbs.Delete);
 319    }
 20
 21    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 22    {
 023        var authorizationResult = await authorizationService.AuthorizeAsync(User, new NotReadOnlyResource(), Authorizati
 24
 025        if (!authorizationResult.Succeeded)
 26        {
 027            await Send.ForbiddenAsync(cancellationToken);
 028            return;
 29        }
 30
 031        var deleted = await workflowDefinitionManager.DeleteByIdAsync(request.Id, cancellationToken);
 32
 033        if (!deleted)
 034            await Send.NotFoundAsync(cancellationToken);
 35        else
 036            await Send.NoContentAsync(cancellationToken);
 037    }
 38}