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
@@ -0,0 +1,34 @@
using FastEndpoints;
using PyroFetes.DTO.Price.Request;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Prices;
namespace PyroFetes.Endpoints.Suppliers;
public class PatchPriceEndpoint(
PricesRepository pricesRepository,
AutoMapper.IMapper mapper) : Endpoint<PatchPriceSellingPriceDto>
{
public override void Configure()
{
Patch("/prices/{@ProductId}/{@SupplierId}/SellingPrice", x => new { x.ProductId, x.SupplierId });
AllowAnonymous();
}
public override async Task HandleAsync(PatchPriceSellingPriceDto req, CancellationToken ct)
{
Price? price = await pricesRepository.SingleOrDefaultAsync(new GetPriceByProductIdAndSupplierIdSpec(req.ProductId, req.SupplierId), ct);
if (price is null)
{
await Send.NotFoundAsync(ct);
return;
}
mapper.Map(req, price);
await pricesRepository.SaveChangesAsync(ct);
await Send.NoContentAsync(ct);
}
}