From 7b7d1973844dcddad0e2e07deaa072750120e6fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=ABl=20Mugnier?= Date: Tue, 26 Oct 2021 16:06:36 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20-=20Correction=20de=20la=20r=C3=A9cup?= =?UTF-8?q?=C3=A9ration=20du=20user=20supprim=C3=A9=20pour=20nettoyer=20se?= =?UTF-8?q?s=20donn=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/GenerateDeliveryBatchFormsCommand.cs | 4 +++- Sheaft.Mediatr/User/Commands/RemoveUserDataCommand.cs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Sheaft.Mediatr/DeliveryBatch/Commands/GenerateDeliveryBatchFormsCommand.cs b/Sheaft.Mediatr/DeliveryBatch/Commands/GenerateDeliveryBatchFormsCommand.cs index eac1fdf72..ecb113b2b 100644 --- a/Sheaft.Mediatr/DeliveryBatch/Commands/GenerateDeliveryBatchFormsCommand.cs +++ b/Sheaft.Mediatr/DeliveryBatch/Commands/GenerateDeliveryBatchFormsCommand.cs @@ -46,7 +46,9 @@ public GenerateDeliveryBatchFormsCommandHandler( public async Task Handle(GenerateDeliveryBatchFormsCommand request, CancellationToken token) { - var deliveryBatch = await _context.DeliveryBatches.SingleAsync(d => d.Id == request.DeliveryBatchId, token); + var deliveryBatch = await _context.DeliveryBatches.SingleOrDefaultAsync(d => d.Id == request.DeliveryBatchId, token); + if (deliveryBatch == null) + return Result.Failure($"DeliveryBatch {request.DeliveryBatchId} was not found."); var outputDocument = new PdfDocument(); Result blobResult = null; diff --git a/Sheaft.Mediatr/User/Commands/RemoveUserDataCommand.cs b/Sheaft.Mediatr/User/Commands/RemoveUserDataCommand.cs index ccf08bbc3..cc8844c0a 100644 --- a/Sheaft.Mediatr/User/Commands/RemoveUserDataCommand.cs +++ b/Sheaft.Mediatr/User/Commands/RemoveUserDataCommand.cs @@ -46,7 +46,7 @@ public RemoveUserDataCommandHandler( public async Task> Handle(RemoveUserDataCommand request, CancellationToken token) { - var entity = await _context.Users.FirstOrDefaultAsync(c => c.Id == request.UserId, token); + var entity = await _context.Users.IgnoreQueryFilters().SingleOrDefaultAsync(c => c.Id == request.UserId, token); if (entity == null) return Failure("L'utilisateur est introuvable.");