using FastEndpoints; using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Contact.Response; namespace PyroFetes.Endpoints.Contact; public class GetAllContactxuest(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> { public override void Configure() { Get ("/api/contacts"); AllowAnonymous(); } public override async Task HandleAsync(CancellationToken ct) { List contacts = await pyroFetesDbContext.Contacts.Select(x => new GetContactDto() { Id = x.Id, LastName = x.LastName, FirstName = x.FirstName, PhoneNumber = x.PhoneNumber, Email = x.Email, Address = x.Address, Role = x.Role, }).ToListAsync(ct); await Send.OkAsync(contacts, ct); } }