Files
Projet4/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs
2025-12-04 16:53:00 +01:00

26 lines
847 B
C#

using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.HistoryOfApproval.Response;
namespace PyroFetes.Endpoints.HistoryOfApproval;
public class GetAllHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetHistoryOfApprovalDto>>
{
public override void Configure()
{
Get ("/historyofapprovals");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetHistoryOfApprovalDto> historyOfApprovals= await pyroFetesDbContext.HistoryOfApprovals.Select(x => new GetHistoryOfApprovalDto()
{
Id = x.Id,
DeliveryDate = x.DeliveryDate,
ExpirationDate = x.ExpirationDate,
}).ToListAsync(ct);
await Send.OkAsync(historyOfApprovals, ct);
}
}