forked from sanchezvem/PyroFetes
AJout des DTO et endpoint sur le nouveau git
This commit is contained in:
32
PyroFetes/Endpoints/Supplier/GetAllSupplierEndpoint.cs
Normal file
32
PyroFetes/Endpoints/Supplier/GetAllSupplierEndpoint.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using API.DTO.Supplier.Response;
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace PyroFetes.Endpoints.Supplier;
|
||||
|
||||
public class GetAllSuppliersEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetSupplierDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/suppliers");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
List<GetSupplierDto> responseDto = await pyrofetesdbcontext.Suppliers
|
||||
.Select(s => new GetSupplierDto
|
||||
{
|
||||
Id = s.Id,
|
||||
Name = s.Name!,
|
||||
Email = s.Email!,
|
||||
PhoneNumber = s.Phone!,
|
||||
Adress = s.Address!,
|
||||
ZipCode = s.ZipCode,
|
||||
City = s.City!
|
||||
})
|
||||
.ToListAsync(ct);
|
||||
|
||||
await Send.OkAsync(responseDto, ct);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user