< 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: 31
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.Labels.Contracts;
 2using Elsa.Workflows;
 3using FastEndpoints;
 4using JetBrains.Annotations;
 5
 6namespace Elsa.Labels.Endpoints.Labels.Post;
 7
 8[PublicAPI]
 9internal class Create : Endpoint<Request, Response, LabelMapper>
 10{
 11    private readonly ILabelStore _store;
 12
 013    public Create(ILabelStore store, IIdentityGenerator identityGenerator)
 14    {
 015        _store = store;
 016    }
 17
 18    public override void Configure()
 19    {
 020        Post("/labels");
 021        Policies(Constants.PolicyName);
 022    }
 23
 24    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 25    {
 026        var label = Map.ToEntity(request);
 027        await _store.SaveAsync(label, cancellationToken);
 028        var response = Map.FromEntity(label);
 029        await Send.CreatedAtAsync<Get.Get>(new { Id = label.Id }, response, cancellation: cancellationToken);
 030    }
 31}