diff --git a/src/ReC.Application/RecActions/Commands/DeleteRecActionsCommand.cs b/src/ReC.Application/RecActions/Commands/DeleteRecActionsCommand.cs index a6c6118..abc2a64 100644 --- a/src/ReC.Application/RecActions/Commands/DeleteRecActionsCommand.cs +++ b/src/ReC.Application/RecActions/Commands/DeleteRecActionsCommand.cs @@ -1,5 +1,7 @@ using DigitalData.Core.Abstraction.Application.Repository; +using DigitalData.Core.Exceptions; using MediatR; +using Microsoft.EntityFrameworkCore; using ReC.Domain.Entities; namespace ReC.Application.RecActions.Commands; @@ -11,8 +13,12 @@ public class DeleteRecActionsCommand : IRequest public class DeleteRecActionsCommandHandler(IRepository repo) : IRequestHandler { - public Task Handle(DeleteRecActionsCommand request, CancellationToken cancel) + public async Task Handle(DeleteRecActionsCommand request, CancellationToken cancel) { - return repo.DeleteAsync(act => act.ProfileId == request.ProfileId, cancel); + // TODO: update DeleteAsync (in Core) to return number of deleted records + if (!await repo.Where(act => act.ProfileId == request.ProfileId).AnyAsync(cancel)) + throw new NotFoundException(); + + await repo.DeleteAsync(act => act.ProfileId == request.ProfileId, cancel); } } \ No newline at end of file