Ejemplo n.º 1
0
        public async Task <IEnumerable <TopSoldProductVM> > Handle(GetTopSoldProductsQuery request, CancellationToken cancellationToken)
        {
            var products = await _topSoldProductService.GetOrderTopSoldProducts();

            var allProducts = await _dataSource.GetProductsAsync();

            var productsVM = products.Join(allProducts, prod => prod.MerchantProductNo, allProd => allProd.MerchantProductNo,
                                           (x, y) => new TopSoldProductVM(y.Name, y.EAN, x.Quantity, x.MerchantProductNo));

            return(productsVM);
        }
Ejemplo n.º 2
0
        public async Task <Unit> Handle(UpdateStockCommand request, CancellationToken cancellationToken)
        {
            var products = await _topSoldProductService.GetOrderTopSoldProducts();

            var updatedMerchantNoExist = products.Any(x => x.MerchantProductNo == request.MerchantProductNo);

            if (!updatedMerchantNoExist)
            {
                throw new UpdatedMerchantProductNoDoesNotExistException(request.MerchantProductNo);
            }

            await _dataSource.UpdateProductStock(request.MerchantProductNo, 25);

            return(Unit.Value);
        }