34 lines
941 B
C#
34 lines
941 B
C#
using FastEndpoints;
|
|
using PyroFetes.DTO.Staff.Request;
|
|
using PyroFetes.DTO.Staff.Response;
|
|
|
|
namespace PyroFetes.Endpoints.Staff;
|
|
|
|
public class CreateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateStaffDto, GetStaffDto>
|
|
{
|
|
public override void Configure()
|
|
{
|
|
Post("/api/availabilities");
|
|
AllowAnonymous();
|
|
}
|
|
|
|
|
|
public override async Task HandleAsync(CreateStaffDto req, CancellationToken ct)
|
|
{
|
|
Models.Staff staff = new()
|
|
{
|
|
F4T2NumberApproval = req.F4T2NumberApproval,
|
|
F4T2ExpirationDate = req.F4T2ExpirationDate,
|
|
};
|
|
pyroFetesDbContext.Add(staff);
|
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
|
|
|
GetStaffDto response = new()
|
|
{
|
|
F4T2NumberApproval = staff.F4T2NumberApproval,
|
|
F4T2ExpirationDate = staff.F4T2ExpirationDate,
|
|
};
|
|
|
|
await Send.OkAsync(response, ct);
|
|
}
|
|
} |