17 lines
667 B
C#
17 lines
667 B
C#
namespace Netina.Repository.Handlers.Reviews;
|
|
|
|
public class GetReviewQueryHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler<GetReviewQuery, ReviewLDto>
|
|
{
|
|
public async Task<ReviewLDto> Handle(GetReviewQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var review = await repositoryWrapper.SetRepository<Review>()
|
|
.TableNoTracking
|
|
.Where(r => r.Id == request.Id)
|
|
.Select(ReviewMapper.ProjectToLDto)
|
|
.FirstOrDefaultAsync(cancellationToken);
|
|
if (review == null)
|
|
throw new AppException("Review not found", ApiResultStatusCode.NotFound);
|
|
|
|
return review;
|
|
}
|
|
} |