Updated using directives to include necessary dependencies for repository and domain entities. Introduced the DeleteOutResCommandHandler class to handle DeleteOutResCommand requests. The handler uses IRepository<OutRes> to delete records based on ActionId or ProfileId. Implemented asynchronous deletion logic with support for cancellation tokens.
20 lines
607 B
C#
20 lines
607 B
C#
using DigitalData.Core.Abstraction.Application.Repository;
|
|
using MediatR;
|
|
using ReC.Domain.Entities;
|
|
|
|
namespace ReC.Application.OutResults.Commands;
|
|
|
|
public record DeleteOutResCommand : IRequest
|
|
{
|
|
public long? ActionId { get; init; }
|
|
|
|
public long? ProfileId { get; init; }
|
|
}
|
|
|
|
public class DeleteOutResCommandHandler(IRepository<OutRes> repo) : IRequestHandler<DeleteOutResCommand>
|
|
{
|
|
public Task Handle(DeleteOutResCommand request, CancellationToken cancel)
|
|
{
|
|
return repo.DeleteAsync(x => x.ActionId == request.ActionId || x.Action!.ProfileId == request.ProfileId, cancel);
|
|
}
|
|
} |