17:17 09/10

This commit is contained in:
2025-10-09 17:17:42 +02:00
parent 1734ec0219
commit 91b4aca2fa
76 changed files with 815 additions and 388 deletions

View File

@@ -6,17 +6,17 @@ public class DeleteMaterialRequest
{
public int Id { get; set; }
}
public class DeleteMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint<DeleteMaterialRequest>
public class DeleteMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteMaterialRequest>
{
public override void Configure()
{
Delete("/api/materials/{@id}", x => new { x.Id });
Delete("/materials/{@id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(DeleteMaterialRequest req, CancellationToken ct)
{
Models.Material? materialToDelete = await appDbContext
Models.Material? materialToDelete = await pyrofetesdbcontext
.Materials
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
@@ -27,8 +27,8 @@ public class DeleteMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint<
return;
}
appDbContext.Materials.Remove(materialToDelete);
await appDbContext.SaveChangesAsync(ct);
pyrofetesdbcontext.Materials.Remove(materialToDelete);
await pyrofetesdbcontext.SaveChangesAsync(ct);
await Send.NoContentAsync(ct);
}