using FastEndpoints; using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Communication.Request; using PyroFetes.DTO.Communication.Response; namespace PyroFetes.Endpoints.Communication; public class GetCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { Get ("/communications/{@Id}", x => new { x.Id }); AllowAnonymous(); } public override async Task HandleAsync(GetCommunicationRequest database, CancellationToken ct) { Models.Communication? databaseCommunications = await pyroFetesDbContext.Communications.SingleOrDefaultAsync(x => x.Id == database.Id, cancellationToken: ct); if (databaseCommunications == null) { await Send.NotFoundAsync(ct); return; } GetCommunicationDto dto = new() { Id = databaseCommunications.Id, Calling = databaseCommunications.Calling, Email = databaseCommunications.Email, Meeting = databaseCommunications.Meeting }; await Send.OkAsync(dto, ct); } }