< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.WorkflowInstances.Variables.Post.ResolvedVariableModel
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Variables/Post/Endpoint.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 1
Coverable lines: 1
Total lines: 42
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
get_Id()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Variables/Post/Endpoint.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Models;
 3using Elsa.Workflows.Management;
 4using JetBrains.Annotations;
 5using Microsoft.AspNetCore.Http;
 6using Open.Linq.AsyncExtensions;
 7
 8namespace Elsa.Workflows.Api.Endpoints.WorkflowInstances.Variables.Post;
 9
 10[UsedImplicitly]
 11internal class List(IWorkflowInstanceVariableManager workflowInstanceVariableManager) : ElsaEndpoint<Request, ListRespon
 12{
 13    public override void Configure()
 14    {
 15        Post("/workflow-instances/{id}/variables");
 16        ConfigurePermissions("write:workflow-instances");
 17    }
 18
 19    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 20    {
 21        var workflowInstanceId = Route<string>("id");
 22
 23        if (string.IsNullOrWhiteSpace(workflowInstanceId))
 24        {
 25            AddError("The workflow instance ID is required.");
 26            await Send.ErrorsAsync(StatusCodes.Status400BadRequest, cancellationToken);
 27            return;
 28        }
 29
 30        var resolvedVariables = await workflowInstanceVariableManager.SetVariablesAsync(workflowInstanceId, request.Vari
 31        var variableModels = resolvedVariables.Select(x => new ResolvedVariableModel(x.Variable.Id, x.Variable.Name, x.V
 32        var response = new ListResponse<ResolvedVariableModel>(variableModels);
 33        await Send.OkAsync(response, cancellationToken);
 34    }
 35}
 36
 37internal class Request
 38{
 39    public ICollection<VariableUpdateValue> Variables { get; set; } = null!;
 40}
 41
 042internal record ResolvedVariableModel(string Id, string Name, object? Value);

Methods/Properties

get_Id()