Staff DTO / Request Finished 09/10
This commit is contained in:
27
PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs
Normal file
27
PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.DTO.Staff.Response;
|
||||
|
||||
namespace PyroFetes.Endpoints.Staff;
|
||||
|
||||
public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetStaffDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get ("/api/availabilities");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
List<GetStaffDto> staff = await pyroFetesDbContext.Staffs.Select(x => new GetStaffDto()
|
||||
{
|
||||
Id = x.Id,
|
||||
F4T2NumberApproval = x.F4T2NumberApproval,
|
||||
F4T2ExpirationDate = x.F4T2ExpirationDate,
|
||||
|
||||
}).ToListAsync(ct);
|
||||
|
||||
await Send.OkAsync(staff, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user