public FilterConditionsProducts(IEFContext <Location> location, IEFContext <LocationVoucher> dbLocationVoucher, IVoucher dbVoucher) { _dbLocation = location; _dbLocationVoucher = dbLocationVoucher; _dbVoucher = dbVoucher; }
public void ApplyVoucher(IVoucher voucher) { try { if (!voucher.CanBeAppliedToCart(Cart)) { return; } var appliedVoucher = new VoucherAppliedDecorator(voucher); appliedVoucher.Apply(Cart); Cart.Vouchers.Add(appliedVoucher); } catch (OfferVoucherBasketTotalTooLowException exception) { Cart.Message = $"You have not reached the spend threshold for voucher {voucher.Code}. Spend another £{exception.AmountToSpendStill} to receive £{voucher.Value} discount from your basket total."; } catch (VoucherDoesNotContainProductCategoryException exception) { Cart.Message = $"There are no products in your basket applicable to Voucher {voucher.Code} ."; } catch (GiftVoucherBasketTotalTooLowException exception) { Cart.Message = $"There are no items in your basket applicable to Voucher {voucher.Code} ."; } catch (Exception exception) { } }
public Position Move(IVoucher voucher) { Position position = voucher.Position; switch (voucher.Position.CardinalPoint) { case CardinalPoint.North: position.CardinalPoint = CardinalPoint.West; break; case CardinalPoint.West: position.CardinalPoint = CardinalPoint.South; break; case CardinalPoint.South: position.CardinalPoint = CardinalPoint.East; break; case CardinalPoint.East: position.CardinalPoint = CardinalPoint.North; break; } return(position); }
public VoucherDataEntryWindow(IVoucher voucherView, TransactionHeader transactionHeader, TransactionDetail transactionDetail) { InitializeComponent(); _member = new Member(); _account = new Account(); _transactionDetail = (TransactionDetail)transactionDetail.Clone(); DataContext = _transactionDetail; HeaderGrid.DataContext = transactionHeader; _voucherView = voucherView; _transactionHeader = transactionHeader; // set proper button caption if (_transactionDetail.TransactionDetailId > 0) { UpdateButton.Content = "Update"; FormTitle.Content = Title = "Update Current Detail"; } else { UpdateButton.Content = "Insert"; FormTitle.Content = Title = "Insert New Detail"; } }
private bool Check_For_Duplicate_Voucher(IVoucher c) { if (Vouchers.Count(o => o.Voucher_Code == c.Voucher_Code) > 0) { return(true); } return(false); }
public void ProcessVoucher(IVoucher vc, IBasket bkt, IBasketVoucher bv) { if (vc.MinSpend < bkt.BasketTotal()) { bv.Value = -vc.Value; bv.VoucherCode = vc.VoucherCode; bv.VoucherDescription = vc.VoucherDescription; bv.VoucherId = vc.VoucherId; bkt.AddBasketVoucher(bv); } }
public void ProcessVoucher(IVoucher voucher, IBasket basket, IBasketVoucher basketVoucher) { if (voucher.MinSpend < basket.BasketTotal()) { basketVoucher.Value = voucher.Value; basketVoucher.VoucherCode = voucher.VoucherCode; basketVoucher.VoucherDescription = voucher.VoucherDescription; basketVoucher.VoucherId = voucher.VoucherId; basket.AddBasketVoucher(basketVoucher); } }
public void ProcessVoucher(IVoucher voucher, IBasket basket, IBasketVoucher basketVoucher) { if (voucher.MinSpend > basket.BasketTotal()) { basketVoucher.Value = voucher.Value; basketVoucher.VoucherCode = voucher.VoucherCode; basketVoucher.VoucherDescription = voucher.VoucherDescription; basketVoucher.VoucherId = voucher.VoucherId; basket.AddBasketVoucher(basketVoucher); } }
public void ProcessVoucher(IVoucher vc, IBasket bkt, IBasketVoucher bv) { decimal basketTotal = bkt.BasketTotal(); if (vc.MinSpend < basketTotal) { bv.Value = -vc.Value * (basketTotal / 100); bv.VoucherCode = vc.VoucherCode; bv.VoucherDescription = vc.VoucherDescription; bv.VoucherId = vc.VoucherId; bkt.AddBasketVoucher(bv); } }
public void ProcessVoucher(IVoucher voucher, IBasket basket, IBasketVoucher basketVoucher) { decimal basketTotal = basket.BasketTotal(); if (voucher.MinSpend < basketTotal) { basketVoucher.Value = voucher.Value * (basketTotal / 100) - 1; basketVoucher.VoucherCode = voucher.VoucherCode; basketVoucher.VoucherDescription = voucher.VoucherDescription; basketVoucher.VoucherId = voucher.VoucherId; basket.AddBasketVoucher(basketVoucher); } }
public bool Apply_Voucher(IVoucher v) { if (Check_For_Duplicate_Voucher(v)) { return(false); } this.Vouchers.Add(v); if (v is OfferVoucher) { Offer_Voucher = (OfferVoucher)v; } return(true); }
public AdminController(IProductRepository repo, IStockRepository stockRepo, ImagesDbContext context, IEFContext <Transport> dbTransport, IVoucher dbVoucher, IEFContext <Location> dbLocation, IEFContext <Categories> dbCategories) { _repository = repo; _stockRepository = stockRepo; _imagesDb = context; _dbTransport = dbTransport; _dbVoucher = dbVoucher; _dbLocation = dbLocation; _dbCategories = dbCategories; }
private static void Basket1() { Console.WriteLine("Basket 1"); Console.WriteLine(""); IProduct_Factory product_Factory = new Product_Factory(); IProduct Hat = product_Factory.Create_Product_Stock_Item(description: "Hat", price: (decimal)10.50, categories: null); IProduct Jumper = product_Factory.Create_Product_Stock_Item(description: "Jumper", price: (decimal)54.65, categories: null); IVoucher_Factory factory = new Voucher_Factory(); IVoucher off = factory.Create_Gift_Voucher(discount: 5, code: "XXX-XXX", description: ""); Baskets.IBasket Basket = new Baskets.Basket(); Basket.Add_To_Basket(Hat, 1); Basket.Add_To_Basket(Jumper, 1); Basket.Apply_Voucher(off); Console.WriteLine(Basket.ToString()); }
private static void Basket5() { Console.WriteLine("Basket 5"); Console.WriteLine(""); Product_Factory product_Factory = new Product_Factory(); IProduct Hat = product_Factory.Create_Product_Stock_Item(description: "Hat", price: (decimal)25, categories: null); IProduct Voucher = product_Factory.Create_Product_Voucher(description: "£30.00 Gift Voucher", price: (decimal)30); IVoucher_Factory factory = new Voucher_Factory(); IVoucher off = factory.Create_Offer_Voucher(null, 5, "YYY-YYY", "£5.00 off baskets over £50.00", 50); Baskets.IBasket Basket = new Baskets.Basket(); Basket.Add_To_Basket(product: Hat, Quantity: 1); Basket.Add_To_Basket(product: Voucher, Quantity: 1); Basket.Apply_Voucher(off); Console.WriteLine(Basket.ToString()); }
public ProductController(IProductRepository repository, IStockRepository stockRepository, ImagesDbContext context, IFilterConditionsProducts filterConditions, IEFContext <Transport> dbTransport, IVoucher dbVoucher, IEFContext <Location> dbLocation, IEFContext <Categories> dbCategories) { _repository = repository; _stockRepository = stockRepository; _imagesDb = context; _filterConditions = filterConditions; _dbTransport = dbTransport; _dbVoucher = dbVoucher; _dbLocation = dbLocation; _dbCategories = dbCategories; }
private static void Basket2() { Console.WriteLine("Basket 2"); Console.WriteLine(""); IProduct_Factory product_Factory = new Product_Factory(); IProduct Hat = product_Factory.Create_Product_Stock_Item(description: "Hat", price: (decimal)25, categories: null); IProduct Jumper = product_Factory.Create_Product_Stock_Item(description: "Jumper", price: (decimal)26, categories: null); IVoucher_Factory factory = new Voucher_Factory(); IVoucher off = factory.Create_Offer_Voucher(Applies_To: new List <Product_Category>() { Product_Category.Head_Gear }, discount: 5, code: "YYY-YYY", description: "£5.00 off Head Gear in baskets over £50.00", minimumSpend: 50); Baskets.IBasket Basket = new Baskets.Basket(); Basket.Add_To_Basket(Hat, 1); Basket.Add_To_Basket(Jumper, 1); Basket.Apply_Voucher(off); Console.WriteLine(Basket.ToString()); }
private static void Basket4() { Console.WriteLine("Basket 4"); Console.WriteLine(""); Product_Factory Product_Factory = new Product_Factory(); IProduct Hat = Product_Factory.Create_Product_Stock_Item(description: "Hat", price: (decimal)25, categories: null); IProduct Jumper = Product_Factory.Create_Product_Stock_Item(description: "Jumper", price: (decimal)26, categories: null); IVoucher_Factory factory = new Voucher_Factory(); IVoucher Gift_Voucher = factory.Create_Gift_Voucher(discount: 5, code: "YYY-YYY", description: ""); IVoucher Offer_Voucher = factory.Create_Offer_Voucher(Applies_To: null, discount: 5, code: "XXX-XXX", description: "£5.00 off baskets over £50.00", minimumSpend: 50); Baskets.IBasket Basket = new Baskets.Basket(); Basket.Add_To_Basket(product: Hat, Quantity: 1); Basket.Add_To_Basket(product: Jumper, Quantity: 1); Basket.Apply_Voucher(Offer_Voucher); Basket.Apply_Voucher(Gift_Voucher); Console.WriteLine(Basket.ToString()); }
private static void Basket3() { Console.WriteLine("Basket 3"); Console.WriteLine(""); Product_Factory Product_Factory = new Product_Factory(); IProduct Hat = Product_Factory.Create_Product_Stock_Item(description: "Hat", price: (decimal)25, categories: null); IProduct Jumper = Product_Factory.Create_Product_Stock_Item(description: "Jumper", price: (decimal)26, categories: null); IProduct Head_Light = Product_Factory.Create_Product_Stock_Item(description: "Head Light", price: (decimal)3.50, categories: new List <Product_Category>() { Product_Category.Head_Gear }); IVoucher_Factory Factory = new Voucher_Factory(); IVoucher off = Factory.Create_Offer_Voucher(Applies_To: new List <Product_Category>() { Product_Category.Head_Gear }, discount: 5, code: "XXX-XXX", description: "£5.00 off Head Gear in baskets over £50.00", minimumSpend: null); Baskets.IBasket basket = new Baskets.Basket(); basket.Add_To_Basket(Hat, 1); basket.Add_To_Basket(Jumper, 1); basket.Add_To_Basket(Head_Light, 1); basket.Apply_Voucher(off); Console.WriteLine(basket.ToString()); }
public VoucherDecorator(IVoucher voucher) { Voucher = voucher; }
public VoucherAppliedDecorator(IVoucher voucher) : base(voucher) { }
public void AddVoucher(IVoucher voucher) { vouchers.Add(voucher); }
public void Add(IVoucher voucher) { voucherManager.AddVoucher(voucher); }
public Basket(IVoucher voucher) { _voucher = voucher; }
public CartValueVisitor(IVoucher voucher) { this.voucher = voucher; }