private static Cart LoadCart() { // create the cart Cart cart = new Cart(new Member("Rohan")); // add items to the cart GenericProduct Trouser = new GenericProduct("Trouser", 110m); cart.AddLineItem(Trouser, 5); EventItem race = new EventItem("Ticket", 90m); cart.AddLineItem(race, 1); //Add Discount //This would generally be Dynamic from rule engine. Discount buyXGetY = new BuyXGetYFree("Buy 2 Trousers get 1 Trouser free", new List <Product> { Trouser }, 2, 1); buyXGetY.CanBeUsedInJuntionWithOtherDiscounts = false; buyXGetY.SupercedesOtherDiscounts = true; cart.AddDiscount(buyXGetY); return(cart); }
private static Cart LoadCart() { // create the cart Cart cart = new Cart(new Member("Chev")); // add items to the cart Product hat = new Product("Cap", 110m); cart.AddLineItem(hat, 5); var race = new Product("Ticket", 90m); cart.AddLineItem(race, 1); // add discounts Discount percentageOff = new PercentageOffDiscount("10% off all items", 0.10m); percentageOff.CanBeUsedInJuntionWithOtherDiscounts = false; cart.AddDiscount(percentageOff); Discount spendXgetY = new SpendMoreThanXGetYDiscount("Spend more than R100 get 10% off", 100m, 0.1m); spendXgetY.SupercedesOtherDiscounts = true; cart.AddDiscount(spendXgetY); Discount buyXGetY = new BuyXGetYFree("Buy 4 hats get 2 hat free", new List <Product> { hat }, 4, 2) { CanBeUsedInJuntionWithOtherDiscounts = false, SupercedesOtherDiscounts = true }; cart.AddDiscount(buyXGetY); return(cart); }