Refactored endpoints to use services

This commit is contained in:
2026-08-30 14:24:13 +02:00
parent b288450cbb
commit f51b1feb4b
78 changed files with 1494 additions and 870 deletions
@@ -1,4 +1,6 @@
using PostFundManagement.Application.Evidence;
using PostFundManagement.Application.Extensions;
using PostFundManagement.Domain;
using PostFundManagement.Domain.Abstractions;
using PostFundManagement.Domain.Api;
using PostFundManagement.Domain.Extensions;
@@ -10,20 +12,22 @@ public class GetEvidenceFilesEndpoint : IEndpoint
{
public void Map(IEndpointRouteBuilder builder)
{
builder.MapGet("api/evidence/files/{page:int}/{pageSize:int}", async (EvidenceService service, int page = 1, int pageSize = 100, CancellationToken cancellationToken = default) =>
builder.MapGet("api/evidence/files/{page:int}/{pageSize:int}", async (EvidenceService service,
int page = 1, int pageSize = 100, CancellationToken cancellationToken = default) =>
{
var result = await service.GetEvidenceFilesAsync(new Domain.Pagination(page, pageSize), cancellationToken);
var result = await service.GetEvidenceFilesAsync(Pagination.Create(page, pageSize), cancellationToken);
return result.IsSuccess
? Results.Ok(result.Value)
: Results.BadRequest(result.Errors.ToProblems("Failed to get evidence"));
})
.RequireAuthorization()
: Results.BadRequest(result.Errors.ToProblems());
})
.WithDescription("Get a list of all uploaded evidence files metadata")
.WithName(typeof(GetEvidenceFilesEndpoint).ToEndpointName())
.MapToApiVersion(new ApiVersion(1))
.Produces<Domain.Models.Evidence[]>(StatusCodes.Status200OK)
.Produces<Microsoft.AspNetCore.Mvc.ProblemDetails>(StatusCodes.Status400BadRequest)
.Produces(StatusCodes.Status401Unauthorized)
.WithTags(EndpointTags.Evidence);
.WithTags(EndpointTags.Evidence)
.CacheOutput();
}
}