Exemplo n.º 1
0
        private static void Basket1_Calc()
        {
            var shopObject = new Business.ShoppingBasket(GiftVoucherObject);

            Vouchers = new List <Voucher>()
            {
                new Voucher()
                {
                    Amount = 5, VoucherType = (int)VoucherType.Gift, ItemCategory = "REGULAR", VoucherId = "XXX-XXX"
                }
            };
            ShoppingList = new List <ShoppingItem>()
            {
                new ShoppingItem()
                {
                    Name = "Hat", Price = 10.50m, Qty = 1, Category = "HATS", DiscountQualified = true
                },
                new ShoppingItem()
                {
                    Name = "Jumper", Price = 54.65m, Qty = 1, Category = "JUMPERS", DiscountQualified = true
                }
            };

            shopObject.Vouchers     = Vouchers;
            shopObject.ShoppingList = ShoppingList;
            var Result = shopObject.GetFinalBill();

            Console.WriteLine("Basket 1");
            PrintBasketItems(ShoppingList);
            PrintVouchers(Vouchers);
            PrintResult(Result);
        }
Exemplo n.º 2
0
        private static void Basket2_Calc()
        {
            var shopObject = new Business.ShoppingBasket(OfferVoucherObject);

            Vouchers = new List <Voucher>()
            {
                new Voucher()
                {
                    Amount = 5, VoucherType = (int)VoucherType.Offer, ItemCategory = "HEAD GEAR", VoucherId = "YYY-YYY"
                }
            };
            ShoppingList = new List <ShoppingItem>()
            {
                new ShoppingItem()
                {
                    Name = "Hat", Price = 25.00m, Qty = 1, Category = "HATS", DiscountQualified = true
                },
                new ShoppingItem()
                {
                    Name = "Jumper", Price = 26.00m, Qty = 1, Category = "JUMPERS", DiscountQualified = true
                }
            };

            shopObject.Vouchers     = Vouchers;
            shopObject.ShoppingList = ShoppingList;

            var Result = shopObject.GetFinalBill();

            Console.WriteLine("Basket 2");
            PrintBasketItems(ShoppingList);
            PrintVouchers(Vouchers);
            PrintResult(Result);
        }
Exemplo n.º 3
0
        private static void Basket4_Calc()
        {
            var     shopObject    = new Business.ShoppingBasket(GiftVoucherObject);
            decimal TotalDiscount = 0;

            Vouchers = new List <Voucher>()
            {
                new Voucher()
                {
                    Amount = 5, VoucherType = (int)VoucherType.Gift, ItemCategory = "GIFT", VoucherId = "XXX-XXX"
                },
                new Voucher()
                {
                    Amount = 5, VoucherType = (int)VoucherType.Offer, ItemCategory = "REGULAR", VoucherId = "YYY-YYY"
                }
            };
            ShoppingList = new List <ShoppingItem>()
            {
                new ShoppingItem()
                {
                    Name = "Hat", Price = 25.00m, Qty = 1, Category = "HATS", DiscountQualified = true
                },
                new ShoppingItem()
                {
                    Name = "Jumper", Price = 26.00m, Qty = 1, Category = "JUMPERS", DiscountQualified = true
                }
            };

            shopObject.Vouchers     = Vouchers;
            shopObject.ShoppingList = ShoppingList;

            var Result = shopObject.GetFinalBill();

            TotalDiscount += Result.AppliedDiscount;

            //Offer Voucher
            shopObject              = new Business.ShoppingBasket(OfferVoucherObject);
            shopObject.Vouchers     = Vouchers;
            shopObject.ShoppingList = ShoppingList;
            Result                 = shopObject.GetFinalBill();
            TotalDiscount         += Result.AppliedDiscount;
            Result.AppliedDiscount = TotalDiscount;

            Console.WriteLine("Basket 4");
            PrintBasketItems(ShoppingList);
            PrintVouchers(Vouchers);
            PrintResult(Result);
        }