Реализован модуль каталога, миграции, сваггер
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using MediatR;
|
||||
using Nashel.Modules.Catalog.Application.Common;
|
||||
using Nashel.Modules.Catalog.Domain.Repositories;
|
||||
|
||||
namespace Nashel.Modules.Catalog.Application.Queries;
|
||||
|
||||
/// <summary>
|
||||
/// Запрос деталей услуги по ID.
|
||||
/// </summary>
|
||||
public record GetOfferByIdQuery(Guid Id) : IRequest<OfferDto?>;
|
||||
|
||||
public class GetOfferByIdQueryHandler : IRequestHandler<GetOfferByIdQuery, OfferDto?>
|
||||
{
|
||||
private readonly IOfferRepository _repository;
|
||||
|
||||
public GetOfferByIdQueryHandler(IOfferRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
public async Task<OfferDto?> 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
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user