Esempio n. 1
0
        public void AddProduct(int barcode)
        {
            if (!ProductService.ProductExist(barcode))
            {
                return;
            }

            if (DiscountDictionary.ContainsKey(barcode))
            {
                CheckDiscount(barcode);
            }
            else
            {
                if (BuyProductList.ContainsKey(barcode))
                {
                    BuyProductList[barcode].Amount += 1;
                    BuyProductList[barcode].Price  += ProductService.GetProduct(barcode).Price;
                    DiscountDictionary.Add(barcode, 1);
                }
                else
                {
                    BuyProductList.Add(barcode, ProductService.GetProduct(barcode));
                    DiscountDictionary.Add(barcode, 1);
                }
            }
        }
Esempio n. 2
0
        private void AddDiscountedProduct(int barcode)
        {
            var discountProduct = ProductService.GetProduct(barcode);

            discountProduct.Price -= DiscountService.GetDiscount(barcode).DiscountValue;

            BuyProductList[barcode].Amount += 1;
            BuyProductList[barcode].Price  += discountProduct.Price;
            DiscountDictionary.Remove(barcode);
        }
Esempio n. 3
0
        private static DiscountDictionary GetDiscounts()
        {
            var discounts = new DiscountDictionary();

            discounts.Add(0.05M, 2);
            discounts.Add(0.1M, 3);
            discounts.Add(0.2M, 4);
            discounts.Add(0.25M, 5);

            return(discounts);
        }