Files
AP-WEB-PF3/PF3/Endpoints/Staff/GetAllStaffEndpoint.cs
2025-10-16 17:00:36 +02:00

30 lines
768 B
C#

using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PF3.DTO.Staff.Response;
namespace PF3.Endpoints.Staff;
public class GetAllStaffEndpoint(PF3DbContext pf3DbContext) : EndpointWithoutRequest<List<ReadStaffDto>>
{
public override void Configure()
{
Get("/api/staff");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
var staffs = await pf3DbContext.Staffs.ToListAsync(ct);
var result = staffs.Select(s => new ReadStaffDto
{
Id = s.Id,
FirstName = s.FirstName,
LastName = s.LastName,
Profession = s.Profession,
Email = s.Email
}).ToList();
await Send.OkAsync(result, ct);
}
}