Files
Projet4/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs
2025-12-04 15:29:23 +01:00

25 lines
695 B
C#

using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Customer.Response;
namespace PyroFetes.Endpoints.Customer;
public class GetAllCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetCustomerDto>>
{
public override void Configure()
{
Get ("/api/customer");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetCustomerDto> customer= await pyroFetesDbContext.Customers.Select(x => new GetCustomerDto()
{
Id = x.Id,
Note = x.Note,
}).ToListAsync(ct);
await Send.OkAsync(customer, ct);
}
}