< Summary

Information
Class: Elsa.Labels.Endpoints.Labels.Update.Update
Assembly: Elsa.Labels
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Labels/Endpoints/Labels/Update/Update.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 13
Coverable lines: 13
Total lines: 32
Line coverage: 0%
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%210%
Configure()100%210%
HandleAsync()0%620%

File(s)

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

#LineLine coverage
 1using Elsa.Labels.Contracts;
 2using FastEndpoints;
 3using JetBrains.Annotations;
 4
 5namespace Elsa.Labels.Endpoints.Labels.Update;
 6
 7[PublicAPI]
 08internal class Update(ILabelStore store) : Endpoint<Request, Response, LabelMapper>
 9{
 10    public override void Configure()
 11    {
 012        Post("/labels/{id}");
 013        Policies(Constants.PolicyName);
 014    }
 15
 16    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 17    {
 018        var label = await store.FindByIdAsync(request.Id, cancellationToken);
 19
 020        if (label == null)
 21        {
 022            await Send.NotFoundAsync(cancellationToken);
 023            return;
 24        }
 25
 026        label = Map.UpdateEntity(request, label);
 27
 028        await store.SaveAsync(label, cancellationToken);
 029        var response = Map.FromEntity(label);
 030        await Send.OkAsync(response, cancellationToken);
 031    }
 32}