Ajout du niveau d'experience
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.DTO.ExperienceLevel.Response;
|
||||
using PyroFetes.DTO.ExperienceLevel.Request;
|
||||
|
||||
@@ -15,9 +16,20 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext
|
||||
|
||||
public override async Task HandleAsync(CreateExperienceLevelDto req, CancellationToken ct)
|
||||
{
|
||||
Models.Staff? databaseStaff = await pyroFetesDbContext.Staffs.SingleOrDefaultAsync(x => x.Id == req.StaffId, cancellationToken: ct);
|
||||
|
||||
if (databaseStaff == null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
Console.WriteLine("Customer Type not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Models.ExperienceLevel experienceLevel = new()
|
||||
{
|
||||
Label = req.Label
|
||||
Label = req.Label,
|
||||
StaffId = databaseStaff.Id,
|
||||
};
|
||||
pyroFetesDbContext.Add(experienceLevel);
|
||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||
@@ -26,6 +38,7 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext
|
||||
{
|
||||
Id = experienceLevel.Id,
|
||||
Label = experienceLevel.Label,
|
||||
StaffId = experienceLevel.StaffId
|
||||
};
|
||||
|
||||
await Send.OkAsync(response, ct);
|
||||
|
||||
Reference in New Issue
Block a user