Example #1
0
        static void DiscountDemo()
        {
            var xml  = XDocument.Load("discounts.xml");
            var repo = new DiscountRepository(xml);

            var orders = new[] {
                new Order {
                    ItemCount = 2, TotalAmount = 15.0m
                },
                new Order {
                    ItemCount = 7, TotalAmount = 7.0m
                },
                new Order {
                    ItemCount = 10, TotalAmount = 2.0m
                }
            };

            foreach (var order in orders)
            {
                Console.WriteLine("Order: {0}", order);
                foreach (var discount in repo.GetAll())
                {
                    Console.WriteLine("Discount {0} valid?\t{1}!", discount.Code, discount.IsValid(order) ? "Yes" : "No");
                }
                Console.WriteLine();
            }
        }
Example #2
0
        static void DiscountDemo()
        {
            var xml = XDocument.Load("discounts.xml");
            var repo = new DiscountRepository(xml);

            var orders = new[] {
                new Order { ItemCount = 2, TotalAmount = 15.0m },
                new Order { ItemCount = 7, TotalAmount = 7.0m },
                new Order { ItemCount = 10, TotalAmount = 2.0m }
            };

            foreach (var order in orders)
            {
                Console.WriteLine("Order: {0}", order);
                foreach (var discount in repo.GetAll())
                {
                    Console.WriteLine("Discount {0} valid?\t{1}!", discount.Code, discount.IsValid(order) ? "Yes" : "No");
                }
                Console.WriteLine();
            }
        }