Refactor all code

This commit is contained in:
2026-05-24 17:22:03 +01:00
parent fe58e5e7e7
commit 656100d15e
117 changed files with 3317 additions and 1562 deletions
@@ -1,7 +1,5 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.PurchaseOrder.Response;
using PyroFetes.DTO.PurchaseProduct.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.PurchaseOrders;
@@ -13,26 +11,24 @@ public class GetPurchaseOrderRequest
public int Id { get; set; }
}
public class GetPurchaseOrderEndpoint(
PurchaseOrdersRepository purchaseOrdersRepository,
AutoMapper.IMapper mapper) : Endpoint<GetPurchaseOrderRequest, GetPurchaseOrderDto>
public class GetPurchaseOrderEndpoint(PurchaseOrdersRepository purchaseOrdersRepository, AutoMapper.IMapper mapper) : Endpoint<GetPurchaseOrderRequest, GetPurchaseOrderDto>
{
public override void Configure()
{
Get("/purchaseOrders/{@Id}", x => new {x.Id});
Get("/purchaseOrders/{@Id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(GetPurchaseOrderRequest req, CancellationToken ct)
{
PurchaseOrder? purchaseOrder = await purchaseOrdersRepository.FirstOrDefaultAsync(new GetPurchaseOrderByIdSpec(req.Id), ct);
PurchaseOrder? purchaseOrder = await purchaseOrdersRepository.SingleOrDefaultAsync(new GetPurchaseOrderByIdSpec(req.Id), ct);
if (purchaseOrder == null)
if (purchaseOrder is null)
{
await Send.NotFoundAsync(ct);
return;
}
await Send.OkAsync(mapper.Map<GetPurchaseOrderDto>(purchaseOrder), ct);
}
}