< 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: 26
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 Elsa.Authorization;
 2using System.Net.Mime;
 3using System.Text.Json;
 4using Elsa.Abstractions;
 5using Elsa.Common.Multitenancy;
 6using Elsa.Common.Serialization;
 7using Elsa.Models;
 8
 9namespace Elsa.Tenants.Endpoints.Tenants.List;
 10
 011public class Endpoint(ITenantService tenantService) : ElsaEndpointWithoutRequest<ListResponse<Tenant>>
 12{
 13    public override void Configure()
 14    {
 015        Get("/tenants");
 016        RequirePermission(Elsa.Tenants.Permissions.TenantPermissions.Tenants, CoreVerbs.View);
 017    }
 18
 19    public override async Task HandleAsync(CancellationToken ct)
 20    {
 021        var tenants = await tenantService.ListAsync(ct);
 022        var response = new ListResponse<Tenant>(tenants.ToList());
 023        var json = JsonSerializer.Serialize(response, SerializerOptions.ConfigurationJsonSerializerOptions);
 024        await Send.StringAsync(json, contentType: MediaTypeNames.Application.Json, cancellation: ct);
 025    }
 26}