Ejemplo n.º 1
0
        public async Task <IEnumerable <ProductQueryModel> > Handle(GetProductsQuery request, CancellationToken cancellationToken)
        {
            _logger.Debug("Handling GetProductsQuery");

            var products = await _productQueryRepository.GetAllProducts().ConfigureAwait(false);

            return(products);
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <ProductListItemModel> > Handle(ListAllProductsRequest request, CancellationToken cancellationToken)
        {
            var products = await _repository.GetAllProducts();

            if (products == null)
            {
                throw new ProductsNotFoundException("Products not found");
            }

            return(products.Select(p => new ProductListItemModel()
            {
                Id = p.Id,
                ArticleNumber = p.ArticleNumber,
                Currency = p.Currency,
                Description = p.Description,
                ImageUrl = p.ImageUrl,
                Name = p.Name,
                Price = p.Price,
                ProductInfo = p.ProductInfo,
                SupplierName = p.SupplierName
            }));
        }