private void CalculateBasket() { //Reset Message Variables Failed_Voucher = null; Missing_Spend = null; //First part of calculation is to sum all of the items and subtract general gift vouchers decimal runningTotal = Basket_Items.Where(o => o.Product is Product_Stock_Item).Sum(o => o.Product.Price); var originalTotal = runningTotal; Vouchers.Where <IVoucher>(o => o is GiftVoucher).ToList().ForEach(o => o.Calculate_Voucher_Discounts(ref runningTotal, this.Basket_Items)); //Apply Offer Vouchers Discount if (this.Offer_Voucher != null) { Failed_Voucher = this.Offer_Voucher.Calculate_Voucher_Discounts(ref runningTotal, this.Basket_Items); } //Apply Offer Vouchers //apply gift vouchers at the end runningTotal = runningTotal + Basket_Items.Where(o => o.Product is Product_Voucher).Sum(o => o.Product.Price); //Deal with any negative values if (runningTotal < 0) { runningTotal = 0; } Total = runningTotal; }
public bool Add_To_Basket(IProduct product, decimal Quantity) { Basket_Items.Add(new Basket_Items.Basket_Item(product, Quantity)); return(true); }