Creating supplier's endpoints

This commit is contained in:
2025-11-06 17:30:03 +01:00
parent 1c898f9144
commit be0a6a4004
6 changed files with 235 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.PurchaseProduct.Response;
using PyroFetes.DTO.Supplier.Response;
namespace PyroFetes.Endpoints.Supplier;
public class GetAllSuppliersEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetSupplierDto>>
{
public override void Configure()
{
Get("/api/suppliers");
}
public override async Task HandleAsync(CancellationToken ct)
{
var 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);
}
}