using Microsoft.EntityFrameworkCore; namespace NetinaShop.Repository.Handlers.Reviews; public class DeleteReviewCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; public DeleteReviewCommandHandler(IRepositoryWrapper repositoryWrapper) { _repositoryWrapper = repositoryWrapper; } public async Task Handle(DeleteReviewCommand request, CancellationToken cancellationToken) { var review = await _repositoryWrapper.SetRepository().TableNoTracking .FirstOrDefaultAsync(r => r.Id == request.Id, cancellationToken); if (review == null) throw new AppException("Review not found", ApiResultStatusCode.NotFound); _repositoryWrapper.SetRepository().Delete(review); await _repositoryWrapper.SaveChangesAsync(cancellationToken); return true; } }