Endopoint presque fini
This commit is contained in:
27
PF3/Endpoints/SoundCategory/GetAllSoundCategoryEndpoint.cs
Normal file
27
PF3/Endpoints/SoundCategory/GetAllSoundCategoryEndpoint.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PF3.DTO.SoundCategory.Response;
|
||||
|
||||
namespace PF3.Endpoints.SoundCategory;
|
||||
|
||||
public class GetAllSoundCategorysEndpoint(PF3DbContext pf3DbContext) : EndpointWithoutRequest<List<ReadSoundCategoryDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/soundcategorys");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
var soundCategorys = await pf3DbContext.SoundsCategorys.ToListAsync(ct);
|
||||
|
||||
var result = soundCategorys.Select(sC => new ReadSoundCategoryDto
|
||||
{
|
||||
Id = sC.Id,
|
||||
Name = sC.Name
|
||||
}).ToList();
|
||||
|
||||
await Send.OkAsync(result, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user