< Summary

Information
Class: Elsa.Identity.Endpoints.Roles.Delete.Delete
Assembly: Elsa.Identity
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Endpoints/Roles/Delete/Endpoint.cs
Line coverage
22%
Covered lines: 4
Uncovered lines: 14
Coverable lines: 18
Total lines: 42
Line coverage: 22.2%
Branch coverage
0%
Covered branches: 0
Total branches: 2
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%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Endpoints/Roles/Delete/Endpoint.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Identity.Contracts;
 3using JetBrains.Annotations;
 4
 5namespace Elsa.Identity.Endpoints.Roles.Delete;
 6
 7/// <summary>
 8/// An endpoint that deletes a role by ID.
 9/// </summary>
 10[PublicAPI]
 311internal class Delete(IRoleStore roleStore) : ElsaEndpointWithoutRequest
 12{
 13    /// <inheritdoc />
 14    public override void Configure()
 15    {
 316        Delete("/identity/roles/{id}");
 317        ConfigurePermissions("delete:role");
 318    }
 19
 20    /// <inheritdoc />
 21    public override async Task HandleAsync(CancellationToken cancellationToken)
 22    {
 023        var id = Route<string>("id")!;
 24
 025        var role = await roleStore.FindAsync(new()
 026        {
 027            Id = id
 028        }, cancellationToken);
 29
 030        if (role == null)
 31        {
 032            await Send.NotFoundAsync(cancellationToken);
 033            return;
 34        }
 35
 036        await roleStore.DeleteAsync(new()
 037        {
 038            Id = id
 039        }, cancellationToken);
 040        await Send.NoContentAsync(cancellationToken);
 041    }
 42}