Example #1
0
        private void ButtonRemoveSelection_Click(object sender, RoutedEventArgs e) // removes it self
        {
            bool RemoveLimit = false;                                              // only lets you remove one item at a time

            var item  = (sender as FrameworkElement).DataContext;
            int index = ((MainWindow)Application.Current.MainWindow).ListView2.Items.IndexOf(item);

            // checks if a discount is applied then removes an tries to reapply discount
            foreach (IFoodItem I in PizzaViewModel.checkOutList)
            {
                if (I.DiscountApplied == true)
                {
                    I.LoadIngredients(); // loads old ingredients without the discount
                    I.DiscountApplied = false;

                    PizzaViewModel.checkOutList.RemoveAt(index);
                    RemoveLimit = true;
                    MainWindow.DiscountList.Clear();
                    MainWindow.DiscountApplied = false;
                    MainWindow.DiscountEffect  = "";
                    Discounts.Discount1(); // applies the discount agian
                    break;
                }
            }
            if (RemoveLimit == false)
            {
                PizzaViewModel.checkOutList.RemoveAt(index);
            }

            PizzaViewModel.Update();
        }
        public void UpdateDiscount()
        {
            // Handles Discounts
            foreach (IFoodItem I in PizzaViewModel.checkOutList)
            {
                if (I.DiscountApplied == true)
                {
                    I.LoadIngredients(); // loads old ingredients without the discount
                    I.DiscountApplied = false;

                    DiscountList.Clear();

                    DiscountApplied = false;
                    DiscountEffect  = "";
                    Discounts.Discount1(); // applies the discount agian
                }
            }
        }
 // applies coupon deals
 private void BtnDiscount_Click(object sender, RoutedEventArgs e)
 {
     Discounts.Discount1();
     PizzaViewModel.Update();
 }