First Commit 09/10
# Conflicts: # PyroFetes/PyroFetes.csproj
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.DTO.HistoryOfApproval.Request;
|
||||
using PyroFetes.DTO.HistoryOfApproval.Response;
|
||||
|
||||
namespace PyroFetes.Endpoints.HistoryOfApproval;
|
||||
|
||||
public class DeleteHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetHistoryOfApprovalRequest, GetHistoryOfApprovalDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Delete ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetHistoryOfApprovalRequest req, CancellationToken ct)
|
||||
{
|
||||
Models.HistoryOfApproval? databaseHistoryOfApproval = await pyroFetesDbContext.HistoryOfApprovals.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||
|
||||
if (databaseHistoryOfApproval == null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
pyroFetesDbContext.HistoryOfApprovals.Remove(databaseHistoryOfApproval);
|
||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user