Ajout du niveau d'experience
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user