forked from sanchezvem/PyroFetes
28 lines
729 B
C#
28 lines
729 B
C#
using API.DTO.Brand.Response;
|
|
using FastEndpoints;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace PyroFetes.Endpoints.Brand;
|
|
|
|
public class GetAllBrandsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetBrandDto>>
|
|
{
|
|
public override void Configure()
|
|
{
|
|
Get("/api/brands");
|
|
AllowAnonymous();
|
|
}
|
|
|
|
public override async Task HandleAsync(CancellationToken ct)
|
|
{
|
|
|
|
List<GetBrandDto> responseDto = await pyrofetesdbcontext.Brands
|
|
.Select(a => new GetBrandDto
|
|
{
|
|
Id = a.Id,
|
|
Name = a.Name,
|
|
}
|
|
).ToListAsync(ct);
|
|
|
|
await Send.OkAsync(responseDto, ct);
|
|
}
|
|
} |