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

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