forked from sanchezvem/PyroFetes
28 lines
835 B
C#
28 lines
835 B
C#
using API.DTO.Material.Response;
|
|
using FastEndpoints;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace PyroFetes.Endpoints.Material;
|
|
|
|
public class GetAllMaterialsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetMaterialDto>>
|
|
{
|
|
public override void Configure()
|
|
{
|
|
Get("Api/materials");
|
|
AllowAnonymous();
|
|
}
|
|
|
|
public override async Task HandleAsync(CancellationToken ct)
|
|
{
|
|
List<GetMaterialDto> responseDto = await pyrofetesdbcontext.Materials
|
|
.Select(a => new GetMaterialDto
|
|
{
|
|
Id = a.Id,
|
|
Label = a.Name,
|
|
Quantity = a.Quantity,
|
|
WarehouseId = a.WarehouseId,
|
|
}
|
|
).ToListAsync(ct);
|
|
await Send.OkAsync(responseDto, ct);
|
|
}
|
|
} |