forked from sanchezvem/PyroFetes
28 lines
809 B
C#
28 lines
809 B
C#
using PyroFetes.DTO.Classification.Response;
|
|
using FastEndpoints;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace PyroFetes.Endpoints.Classification;
|
|
|
|
public class GetAllClassificationsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetClassificationDto>>
|
|
{
|
|
public override void Configure()
|
|
{
|
|
Get("/api/classifications");
|
|
AllowAnonymous();
|
|
}
|
|
|
|
public override async Task HandleAsync(CancellationToken ct)
|
|
{
|
|
|
|
List<GetClassificationDto> responseDto = await pyrofetesdbcontext.Classifications
|
|
.Select(a => new GetClassificationDto
|
|
{
|
|
Id = a.Id,
|
|
Label = a.Label,
|
|
}
|
|
).ToListAsync(ct);
|
|
|
|
await Send.OkAsync(responseDto, ct);
|
|
}
|
|
} |