forked from sanchezvem/PyroFetes
suppr all 'var' and Models.xxx. And added 's' at the end of all directories endpoints
This commit is contained in:
31
PyroFetes/Endpoints/Suppliers/GetAllSuppliersEndpoint.cs
Normal file
31
PyroFetes/Endpoints/Suppliers/GetAllSuppliersEndpoint.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.DTO.Supplier.Response;
|
||||
|
||||
namespace PyroFetes.Endpoints.Suppliers;
|
||||
|
||||
public class GetAllSuppliersEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetSupplierDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/suppliers");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
List<GetSupplierDto> supplier = await database.Suppliers
|
||||
.Select(supplier => new GetSupplierDto()
|
||||
{
|
||||
Id = supplier.Id,
|
||||
Name = supplier.Name,
|
||||
Email = supplier.Email,
|
||||
Phone = supplier.Phone,
|
||||
Address = supplier.Address,
|
||||
City = supplier.City,
|
||||
ZipCode = supplier.ZipCode,
|
||||
DeliveryDelay = supplier.DeliveryDelay
|
||||
}).ToListAsync(ct);
|
||||
|
||||
await Send.OkAsync(supplier, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user