< Summary

Information
Class: Elsa.Identity.Endpoints.Users.Delete.Delete
Assembly: Elsa.Identity
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Endpoints/Users/Delete/Endpoint.cs
Line coverage
28%
Covered lines: 4
Uncovered lines: 10
Coverable lines: 14
Total lines: 38
Line coverage: 28.5%
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/Users/Delete/Endpoint.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Identity.Contracts;
 3using JetBrains.Annotations;
 4
 5namespace Elsa.Identity.Endpoints.Users.Delete;
 6
 7/// <summary>
 8/// An endpoint that deletes a user by ID.
 9/// </summary>
 10[PublicAPI]
 311internal class Delete(IUserStore userStore) : ElsaEndpointWithoutRequest
 12{
 13    /// <inheritdoc />
 14    public override void Configure()
 15    {
 316        Delete("/identity/users/{id}");
 317        ConfigurePermissions("delete:user");
 318    }
 19
 20    /// <inheritdoc />
 21    public override async Task HandleAsync(CancellationToken cancellationToken)
 22    {
 023        var id = Route<string>("id")!;
 24
 025        var user = await userStore.FindAsync(new()
 026            { Id = id }, cancellationToken);
 27
 028        if (user == null)
 29        {
 030            await Send.NotFoundAsync(cancellationToken);
 031            return;
 32        }
 33
 034        await userStore.DeleteAsync(new()
 035            { Id = id }, cancellationToken);
 036        await Send.NoContentAsync(cancellationToken);
 037    }
 38}