< Summary

Information
Class: Elsa.Labels.Endpoints.Labels.Post.Create
Assembly: Elsa.Labels
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Labels/Endpoints/Labels/Post/Endpoint.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 11
Coverable lines: 11
Total lines: 32
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
Configure()100%210%
HandleAsync()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Labels/Endpoints/Labels/Post/Endpoint.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Labels.Contracts;
 3using Elsa.Workflows;
 4using FastEndpoints;
 5using JetBrains.Annotations;
 6
 7namespace Elsa.Labels.Endpoints.Labels.Post;
 8
 9[PublicAPI]
 10internal class Create : ElsaEndpoint<Request, Response, LabelMapper>
 11{
 12    private readonly ILabelStore _store;
 13
 014    public Create(ILabelStore store, IIdentityGenerator identityGenerator)
 15    {
 016        _store = store;
 017    }
 18
 19    public override void Configure()
 20    {
 021        Post("/labels");
 022        ConfigurePermissions("create:labels");
 023    }
 24
 25    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 26    {
 027        var label = Map.ToEntity(request);
 028        await _store.SaveAsync(label, cancellationToken);
 029        var response = Map.FromEntity(label);
 030        await Send.CreatedAtAsync<Get.Get>(new { Id = label.Id }, response, cancellation: cancellationToken);
 031    }
 32}