25 lines
696 B
C#
25 lines
696 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/customers");
|
|
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);
|
|
}
|
|
} |