Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
using Grand.Business.Core.Queries.Messages;
using Grand.Data;
using Grand.Domain.Catalog;
using Grand.Mediator;
namespace Grand.Business.Messages.Queries.Handlers;
public class GetProductByIdQueryHandler : IRequestHandler<GetProductByIdQuery, Product>
{
private readonly IRepository<Product> _productRepository;
public GetProductByIdQueryHandler(IRepository<Product> productRepository)
{
_productRepository = productRepository;
}
public async Task<Product> Handle(GetProductByIdQuery request, CancellationToken cancellationToken)
{
if (string.IsNullOrWhiteSpace(request.Id))
return null;
return await _productRepository.GetByIdAsync(request.Id);
}
}