Adding Comunication

This commit is contained in:
2025-10-16 17:05:52 +02:00
parent 5cbbfa1434
commit df622c9232
10 changed files with 109 additions and 9 deletions

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using PyroFetes.DTO.Communication.Request;
using PyroFetes.DTO.Communication.Response;
namespace PyroFetes.Endpoints.Communication;
public class CreateCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateCommunicationDto, GetCommunicationDto>
{
public override void Configure()
{
Post("/api/communications");
AllowAnonymous();
}
public override async Task HandleAsync(CreateCommunicationDto req, CancellationToken ct)
{
Models.Communication communication = new()
{
Calling = req.Calling,
Email = req.Email,
Meeting = req.Meeting
};
pyroFetesDbContext.Add(communication);
await pyroFetesDbContext.SaveChangesAsync(ct);
GetCommunicationDto response = new()
{
Calling = req.Calling,
Email = req.Email,
Meeting = req.Meeting
};
await Send.OkAsync(response, ct);
}
}