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,6 +1,5 @@
using PyroFetes.DTO.Material.Response;
using API.DTO.Material.Response;
using FastEndpoints;
using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Material;
@@ -10,17 +9,17 @@ public class GetMaterialRequest
public int Id { get; set; }
}
public class GetMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint<GetMaterialRequest, GetMaterialDto>
public class GetMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetMaterialRequest, GetMaterialDto>
{
public override void Configure()
{
Get("/api/material/{@id}", x => new { x.Id });
Get("/material/{@id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(GetMaterialRequest req, CancellationToken ct)
{
Models.Material? material = await appDbContext
Models.Material? material = await pyrofetesdbcontext
.Materials
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
@@ -34,7 +33,7 @@ public class GetMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint<Get
GetMaterialDto responseDto = new()
{
Id = material.Id,
Label = material.Label,
Label = material.Name,
WarehouseId = material.WarehouseId,
};
await Send.OkAsync(responseDto, ct);