Refactored endpoints to be more functional and more expressive

This commit is contained in:
2026-09-01 11:23:25 +02:00
parent 346cb8da5f
commit 2df5b5c2ed
86 changed files with 1565 additions and 1575 deletions
@@ -3,6 +3,7 @@ using PostFundManagement.Application.Services.Governance;
using PostFundManagement.Domain.Abstractions;
using PostFundManagement.Domain.Extensions;
using PostFundManagement.Domain.Security;
using Problems = Microsoft.AspNetCore.Mvc.ProblemDetails;
namespace PostFundManagement.Api.Endpoints.Governance;
@@ -13,19 +14,17 @@ public class DashboardEndpoint : IEndpoint
{
builder.MapGet("api/governance/dashboard", async (GovernanceService service,
CancellationToken cancellationToken = default) =>
{
var result = await service.GetDashboardAsync(cancellationToken);
return result.IsSuccess
? Results.Ok(result.Value)
: Results.BadRequest(result.Errors.ToProblems());
})
.WithDescription("Get executive portfolio dashboard metrics and KPIs")
.WithName(typeof(DashboardEndpoint).ToEndpointName())
.MapToApiVersion(new ApiVersion(1))
.Produces<Dashboard>(StatusCodes.Status200OK)
.Produces<Microsoft.AspNetCore.Mvc.ProblemDetails>(StatusCodes.Status400BadRequest)
.Produces(StatusCodes.Status401Unauthorized)
.WithTags(EndpointTags.Governance);
await service.GetDashboardAsync(cancellationToken) switch
{
{ IsSuccess: true, Value: var dashboard } => Results.Ok(dashboard),
var r => Results.InternalServerError(r.Errors.ToProblems())
})
.WithDescription("Get executive portfolio dashboard metrics and KPIs")
.WithName(typeof(DashboardEndpoint).ToEndpointName())
.MapToApiVersion(new ApiVersion(1))
.Produces<Dashboard>(StatusCodes.Status200OK)
.Produces(StatusCodes.Status401Unauthorized)
.Produces<Problems>(StatusCodes.Status500InternalServerError)
.WithTags(EndpointTags.Governance);
}
}