< Summary

Information
Class: Elsa.Tenants.Endpoints.Tenants.List.Endpoint
Assembly: Elsa.Tenants
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Tenants/Endpoints/Tenants/List/Endpoint.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 9
Coverable lines: 9
Total lines: 25
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.Tenants/Endpoints/Tenants/List/Endpoint.cs

#LineLine coverage
 1using System.Net.Mime;
 2using System.Text.Json;
 3using Elsa.Abstractions;
 4using Elsa.Common.Multitenancy;
 5using Elsa.Common.Serialization;
 6using Elsa.Models;
 7
 8namespace Elsa.Tenants.Endpoints.Tenants.List;
 9
 010public class Endpoint(ITenantService tenantService) : ElsaEndpointWithoutRequest<ListResponse<Tenant>>
 11{
 12    public override void Configure()
 13    {
 014        Get("/tenants");
 015        ConfigurePermissions("read:tenants");
 016    }
 17
 18    public override async Task HandleAsync(CancellationToken ct)
 19    {
 020        var tenants = await tenantService.ListAsync(ct);
 021        var response = new ListResponse<Tenant>(tenants.ToList());
 022        var json = JsonSerializer.Serialize(response, SerializerOptions.ConfigurationJsonSerializerOptions);
 023        await Send.StringAsync(json, contentType: MediaTypeNames.Application.Json, cancellation: ct);
 024    }
 25}