Refactored Communications and Evidence endpoints

This commit is contained in:
2026-08-28 17:21:41 +02:00
parent e5205f8443
commit b288450cbb
33 changed files with 607 additions and 304 deletions
@@ -1,7 +1,8 @@
using PostFundManagement.Application.Evidence;
using PostFundManagement.Domain.Abstractions;
using PostFundManagement.Domain.Api;
using PostFundManagement.Domain.Configuration.Entities;
using PostFundManagement.Domain.Extensions;
using PostFundManagement.Infrastructure.Database;
namespace PostFundManagement.Api.Endpoints.Evidence;
@@ -11,23 +12,21 @@ public class GetProjectMilestonesEndpoint : IEndpoint
public void Map(IEndpointRouteBuilder builder)
{
builder.MapGet("api/evidence/milestones/project/{projectId:long}", async (long projectId,
IDbContextFactory<ApplicationDbContext> contextFactory, CancellationToken cancellationToken = default) =>
EvidenceService service, CancellationToken cancellationToken = default) =>
{
using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
var result = await service.GetMilestonesByProjectIdAsync(projectId, cancellationToken);
var milestones = await context.Milestones.AsNoTracking()
.Where(m => m.ProjectId == projectId)
.OrderBy(m => m.DueAt)
.ToListAsync(cancellationToken);
return Results.Ok(milestones);
return result.IsSuccess
? Results.Ok(result.Value)
: Results.NotFound();
})
.RequireAuthorization()
.WithDescription("Get a list of milestones for a project")
.WithName(typeof(GetProjectMilestonesEndpoint).ToEndpointName())
.MapToApiVersion(new ApiVersion(1))
.Produces(StatusCodes.Status200OK)
.Produces<Milestone[]>(StatusCodes.Status200OK)
.Produces(StatusCodes.Status401Unauthorized)
.Produces(StatusCodes.Status404NotFound)
.WithTags(EndpointTags.Evidence);
}
}