using API.DTO.Material.Request; using API.DTO.Material.Response; using FastEndpoints; namespace API.Endpoints.Material; public class CreateMaterialEndpoint(AppDbContext appDbContext) : Endpoint { public override void Configure() { Post("/material/create"); AllowAnonymous(); } public override async Task HandleAsync(CreateMaterialDto req, CancellationToken ct) { Models.Material quantity = new() { Name = req.Name, Quantity = req.Quantity, WarehouseId = req.WarehouseId, }; appDbContext.Materials.Add(quantity); await appDbContext.SaveChangesAsync(ct); Console.WriteLine("Material added"); GetMaterialDto responseDto = new() { Id = quantity.Id, WarehouseId = quantity.WarehouseId, Name = req.Name, }; await Send.OkAsync(responseDto, ct); } }