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,5 +1,4 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Supplier.Request;
using PyroFetes.DTO.Supplier.Response;
using PyroFetes.Models;
@@ -8,29 +7,27 @@ using PyroFetes.Specifications.Suppliers;
namespace PyroFetes.Endpoints.Suppliers;
public class PatchSupplierDeliveryDelayEndpoint(
SuppliersRepository suppliersRepository,
AutoMapper.IMapper mapper) : Endpoint<PatchSupplierDeliveryDelayDto, GetSupplierDto>
public class PatchSupplierDeliveryDelayEndpoint(SuppliersRepository suppliersRepository, AutoMapper.IMapper mapper) : Endpoint<PatchSupplierDeliveryDelayDto>
{
public override void Configure()
{
Patch("/suppliers/{@Id}/deliveryDelay", x => new {x.Id});
Patch("/suppliers/{@Id}/deliveryDelay", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(PatchSupplierDeliveryDelayDto req, CancellationToken ct)
{
Supplier? supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.Id), ct);
Supplier? supplier = await suppliersRepository.SingleOrDefaultAsync(new GetSupplierByIdSpec(req.Id), ct);
if (supplier == null)
if (supplier is null)
{
await Send.NotFoundAsync(ct);
return;
}
supplier.DeliveryDelay = req.DeliveryDelay;
await suppliersRepository.UpdateAsync(supplier, ct);
await suppliersRepository.SaveChangesAsync(ct);
await Send.OkAsync(mapper.Map<GetSupplierDto>(supplier), ct);
}
}