using MediatR; using Nashel.Modules.Catalog.Application.Common; using Nashel.Modules.Catalog.Domain.Repositories; namespace Nashel.Modules.Catalog.Application.Queries; /// /// Запрос деталей услуги по ID. /// public record GetOfferByIdQuery(Guid Id) : IRequest; public class GetOfferByIdQueryHandler : IRequestHandler { private readonly IOfferRepository _repository; public GetOfferByIdQueryHandler(IOfferRepository repository) { _repository = repository; } public async Task Handle(GetOfferByIdQuery request, CancellationToken cancellationToken) { var offer = await _repository.GetByIdAsync(request.Id, cancellationToken); if (offer == null) return null; return new OfferDto( offer.Id, offer.OwnerId, offer.CategoryId, offer.Title, offer.Description, offer.Price, offer.Attributes, offer.IsActive ); } }