This commit is contained in:
2025-10-09 16:55:29 +02:00
parent 8a8a47c99c
commit 8f4171a045
134 changed files with 5101 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
using PyroFetes.DTO.Material.Request;
using PyroFetes.DTO.Material.Response;
using FastEndpoints;
namespace PyroFetes.Endpoints.Material;
public class CreateMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint<CreateMaterialDto, GetMaterialDto>
{
public override void Configure()
{
Post("/api/material/create");
AllowAnonymous();
}
public override async Task HandleAsync(CreateMaterialDto req, CancellationToken ct)
{
Models.Material material = new()
{
Label = req.Label,
Quantity = req.Quantity,
WarehouseId = req.WarehouseId,
};
appDbContext.Materials.Add(material);
await appDbContext.SaveChangesAsync(ct);
Console.WriteLine("Material added");
GetMaterialDto responseDto = new()
{
Id = material.Id,
WarehouseId = material.WarehouseId,
Label = req.Label,
};
await Send.OkAsync(responseDto, ct);
}
}