19 lines
716 B
C#
19 lines
716 B
C#
using Netina.Domain.Entities.Comments;
|
|
|
|
namespace Netina.Repository.Handlers.Comments;
|
|
|
|
public class GetCommentQueryHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler<GetCommentQuery, CommentLDto>
|
|
{
|
|
public async Task<CommentLDto> Handle(GetCommentQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var review = await repositoryWrapper.SetRepository<Comment>()
|
|
.TableNoTracking
|
|
.Where(r => r.Id == request.Id)
|
|
.Select(CommentMapper.ProjectToLDto)
|
|
.FirstOrDefaultAsync(cancellationToken);
|
|
if (review == null)
|
|
throw new AppException("Comment not found", ApiResultStatusCode.NotFound);
|
|
|
|
return review;
|
|
}
|
|
} |