Add DeleteRecActionsCommand and handler for deletion
Introduced `DeleteRecActionsCommand` and its handler to enable deletion of `RecAction` entities based on `ProfileId`. Added necessary `using` directives and organized the code under the `ReC.Application.RecActions.Commands` namespace. The handler uses dependency injection for the repository and performs asynchronous deletion with cancellation support.
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
using DigitalData.Core.Abstraction.Application.Repository;
|
||||||
|
using MediatR;
|
||||||
|
using ReC.Domain.Entities;
|
||||||
|
|
||||||
|
namespace ReC.Application.RecActions.Commands;
|
||||||
|
|
||||||
|
public class DeleteRecActionsCommand : IRequest
|
||||||
|
{
|
||||||
|
public long ProfileId { get; init; } = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DeleteRecActionsCommandHandler(IRepository<RecAction> repo) : IRequestHandler<DeleteRecActionsCommand>
|
||||||
|
{
|
||||||
|
public async Task Handle(DeleteRecActionsCommand request, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
await repo.DeleteAsync(act => act.ProfileId == request.ProfileId, cancel);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user