Ajout du niveau d'experience

This commit is contained in:
2026-06-11 11:06:31 +02:00
parent 35c99928ad
commit 5d16138ed8
16 changed files with 2270 additions and 26 deletions
@@ -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);
@@ -1,4 +1,5 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.HistoryOfApproval.Request;
using PyroFetes.DTO.HistoryOfApproval.Response;
@@ -15,10 +16,21 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
public override async Task HandleAsync(CreateHistoryOfApprovalDto 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.HistoryOfApproval historyOfApproval = new()
{
DeliveryDate = req.DeliveryDate,
ExpirationDate = req.ExpirationDate
ExpirationDate = req.ExpirationDate,
StaffId = databaseStaff.Id,
};
pyroFetesDbContext.Add(historyOfApproval);
await pyroFetesDbContext.SaveChangesAsync(ct);
@@ -27,7 +39,8 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
{
Id = historyOfApproval.Id,
DeliveryDate = historyOfApproval.DeliveryDate,
ExpirationDate = historyOfApproval.ExpirationDate
ExpirationDate = historyOfApproval.ExpirationDate,
StaffId = historyOfApproval.StaffId,
};
await Send.OkAsync(response, ct);
@@ -19,6 +19,7 @@ public class GetAllHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
Id = x.Id,
DeliveryDate = x.DeliveryDate,
ExpirationDate = x.ExpirationDate,
StaffId = x.StaffId,
}).ToListAsync(ct);
await Send.OkAsync(historyOfApprovals, ct);
@@ -14,11 +14,12 @@ public class GetAllProvidersEndpoint(PyroFetesDbContext pyroFetesDbContext) : En
public override async Task HandleAsync(CancellationToken ct)
{
List<GetProviderDto> provider= await pyroFetesDbContext.ServiceProviders.Select(x => new GetProviderDto()
List<GetProviderDto> provider= await pyroFetesDbContext.ServiceProviders.Include(x => x.ProviderType).Select(x => new GetProviderDto()
{
Id = x.Id,
Price = x.Price,
ProviderTypeId = x.ProviderTypeId,
ProviderType = x.ProviderType.Label,
}).ToListAsync(ct);
await Send.OkAsync(provider, ct);
@@ -7,25 +7,28 @@ namespace PyroFetes.Endpoints.Staff;
public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetStaffDto>>
{
public override void Configure()
{
Get ("/staffs");
{
Get("/staffs");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetStaffDto> staff = await pyroFetesDbContext.Staffs.Select(x => new GetStaffDto()
{
Id = x.Id,
FirstName = x.FirstName,
LastName = x.LastName,
Profession = x.Profession,
Email = x.Email,
F4T2NumberApproval = x.F4T2NumberApproval,
F4T2ExpirationDate = x.F4T2ExpirationDate,
}).ToListAsync(ct);
List<GetStaffDto> staff = await pyroFetesDbContext.Staffs
.Include(x => x.ExperienceLevel)
.Select(x => new GetStaffDto()
{
Id = x.Id,
FirstName = x.FirstName,
LastName = x.LastName,
Profession = x.Profession,
Email = x.Email,
F4T2NumberApproval = x.F4T2NumberApproval,
F4T2ExpirationDate = x.F4T2ExpirationDate,
ExperienceLevel = x.ExperienceLevel.Label
}).ToListAsync(ct);
await Send.OkAsync(staff, ct);
}
}