Ejemplo n.º 1
0
        private Models.ShoppingBasket PopulateDiscounts(string productList, Models.ShoppingBasket shoppingBasket, IEnumerable <ProductTable> productTables)
        {
            foreach (var productTable in productTables)
            {
                if (productTable.Discount == null)
                {
                    continue;
                }

                var discount = _discountMapper.MapToDiscount(productTable);

                if (discount == null)
                {
                    continue;
                }
                discount.Qty = productList.Count(p => p == productTable.Sku.ToCharArray()[0]) /
                               productTable.Discount.NumberOfItems;

                if (discount.Qty > 0)
                {
                    shoppingBasket.Discounts.Add(discount);
                }
            }

            return(shoppingBasket);
        }
Ejemplo n.º 2
0
        private Models.ShoppingBasket PopulateItems(string productList, IEnumerable <ProductTable> productTables)
        {
            var shoppingBasket = new Models.ShoppingBasket();

            foreach (var productTable in productTables)
            {
                var item = _productMapper.ProductTableToItem(productTable);

                item.Qty = productList.Count(p => p == productTable.Sku.ToCharArray()[0]);

                shoppingBasket.Items.Add(item);
            }

            return(shoppingBasket);
        }