using FastEndpoints; using Microsoft.EntityFrameworkCore; using PF3.DTO.Staff.Request; using PF3.DTO.Staff.Response; namespace PF3.Endpoints.Staff; public class GetStaffEndpoint(PF3DbContext pf3DbContext) : Endpoint { public override void Configure() { Get("/api/staff/{Id}"); AllowAnonymous(); } public override async Task HandleAsync(IdStaffDto req, CancellationToken ct) { var staff = await pf3DbContext.Staffs .Where(s => s.Id == req.Id) .Select(s => new ReadStaffDto { Id = s.Id, FirstName = s.FirstName, LastName = s.LastName, Profession = s.Profession, Email = s.Email }) .FirstOrDefaultAsync(ct); if (staff is null) { await Send.NotFoundAsync(ct); return; } await Send.OkAsync(staff, ct); } }