provider added
This commit is contained in:
25
PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs
Normal file
25
PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.DTO.Provider.Response;
|
||||
|
||||
namespace PyroFetes.Endpoints.Provider;
|
||||
|
||||
public class GetAllProvidersEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetProviderDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get ("/api/providers");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
List<GetProviderDto> customer= await pyroFetesDbContext.Providers.Select(x => new GetProviderDto()
|
||||
{
|
||||
Id = x.Id,
|
||||
Price = x.Price,
|
||||
}).ToListAsync(ct);
|
||||
|
||||
await Send.OkAsync(customer, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user