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); }
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); } } }