customer type + communication added
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.DTO.Communication.Request;
|
||||
using PyroFetes.DTO.Communication.Response;
|
||||
|
||||
namespace PyroFetes.Endpoints.Communication;
|
||||
|
||||
public class UpdateCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateCommunicationDto, GetCommunicationDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Put ("/api/communications/{@Id}", x => new { x.Id });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(UpdateCommunicationDto req, CancellationToken ct)
|
||||
{
|
||||
Models.Communication? databaseCommunication = await pyroFetesDbContext.Communications.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||
|
||||
if (databaseCommunication == null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
databaseCommunication.Calling = req.Calling;
|
||||
databaseCommunication.Email = req.Email;
|
||||
databaseCommunication.Meeting = req.Meeting;
|
||||
}
|
||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||
|
||||
GetCommunicationDto dto = new()
|
||||
{
|
||||
Id = databaseCommunication.Id,
|
||||
Calling = req.Calling,
|
||||
Email = req.Email,
|
||||
Meeting = req.Meeting,
|
||||
};
|
||||
|
||||
await Send.OkAsync(dto, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user