Initial commit

This commit is contained in:
2026-05-05 10:53:52 +02:00
commit 419e59ef2f
2269 changed files with 313143 additions and 0 deletions
@@ -0,0 +1,36 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Suppliers;
namespace PyroFetes.Endpoints.Suppliers;
public class DeleteSupplierRequest
{
public int Id { get; set; }
}
public class DeleteSupplierEndpoint(SuppliersRepository suppliersRepository) : Endpoint<DeleteSupplierRequest>
{
public override void Configure()
{
Delete("/suppliers/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(DeleteSupplierRequest req, CancellationToken ct)
{
Supplier? supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.Id), ct);
if (supplier == null)
{
await Send.NotFoundAsync(ct);
return;
}
await suppliersRepository.DeleteAsync(supplier, ct);
await Send.NoContentAsync(ct);
}
}