Beispiel #1
0
        /// <summary>
        /// Adds an item to the list
        /// </summary>
        /// <param name="item">Item being added</param>
        public void Add(IOrderItem item)
        {
            if (item is INotifyPropertyChanged notifier)
            {
                notifier.PropertyChanged += OnItemPropertyChange;
            }

            items.Add(item);

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
        }
Beispiel #2
0
 /// <summary>
 /// Adds an order to the list of items, updates subtotal, and communicates with PropertyChanged
 /// </summary>
 /// <param name="item"></param>
 public void Add(IOrderItem item)
 {
     if (item is INotifyPropertyChanged notifier)
     {
         notifier.PropertyChanged += OnItemPropertyChanged;
     }
     items.Add(item);
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SpecialInstructions"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("TotalWithTax"));
 }
Beispiel #3
0
        /// <summary>
        /// Adds the passed item to the list of order items and notifies
        /// the MainWindow that Items has changed. It also subscribes to the
        /// PropertyChanged event handler in each item so it can invoke its
        /// own PropertyChanged event handler.
        /// </summary>
        /// <param name="item">The element to be added to Items.</param>
        public void Add(IOrderItem item)
        {
            double preSubtotal = Subtotal;

            items.Add(item);
            item.PropertyChanged += OnItemChanged;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));

            if (!(Math.Abs(Subtotal - preSubtotal) < 0.001))
            {
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
            }
        }
Beispiel #4
0
        /// <summary>
        /// method to remove an item from an order
        /// </summary>
        /// <param name="item"></param>
        public void Remove(IOrderItem item)
        {
            if (item is INotifyPropertyChanged notifier)
            {
                notifier.PropertyChanged += OnItemPropertyChanged;
            }

            items.Remove(item);
            Subtotal -= item.Price;

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
        }
Beispiel #5
0
 /// <summary>
 /// Adds an item to the order
 /// </summary>
 /// <param name="item"></param>
 public void Add(IOrderItem item)
 {
     items.Add(item);
     if (item is INotifyPropertyChanged pcitem)
     {
         pcitem.PropertyChanged += OnItemChanged;
     }
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Price"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SpecialInstructions"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Total"));
 }
Beispiel #6
0
 /// <summary>
 /// removes an item from items
 /// </summary>
 /// <param name="item">the backing variable for the order</param>
 public void Remove(IOrderItem item)
 {
     if (item is INotifyPropertyChanged notifier)
     {
         notifier.PropertyChanged -= OnItemPropertyChanged;
     }
     items.Remove(item);
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));//was Items
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("OrderNumber"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Price"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SpecialInstructions"));//added 3.11
 }
Beispiel #7
0
        /// <summary>
        /// This method will add everything that is needed to respective list for the client
        /// </summary>
        /// <param name="i">The item needed to be added to the list</param>
        public void Add(IOrderItem i)
        {
            /* Do some computation here to make it easier in the future */
            double priceOfItem           = i.Price;
            string priceOfItemAsCurrency = String.Format("{0:C}", priceOfItem);

            Subtotal += priceOfItem;

            /* Add the computed values to their respective lists */
            items.Add(i);
            itemPrices.Add(priceOfItemAsCurrency);
            InvokePropertyChanged();
        }
Beispiel #8
0
        /// <summary>
        /// This method will remove everything related to the item passed in from the reciept
        /// </summary>
        /// <param name="i">The item needed to be removed to the list</param>
        public void Remove(IOrderItem i)
        {
            /* Do some computation here too to ensure everything is removed */
            double priceOfItem           = i.Price;
            string priceOfItemAsCurrency = String.Format("{0:C}", priceOfItem);

            Subtotal -= priceOfItem;

            /* Remove the computed values to their respective lists */
            items.Add(i);
            itemPrices.Add(priceOfItemAsCurrency);
            InvokePropertyChanged();
        }
Beispiel #9
0
        /// <summary>
        /// On Add, invoke the event, and update he properties.
        /// </summary>
        /// <param name="item"></param>
        public void Add(IOrderItem item)
        {
            items.Add(item);

            if (item is INotifyPropertyChanged changeditem)
            {
                changeditem.PropertyChanged += OnItemPropertyChanged;
            }

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("orderNumber"));
        }
Beispiel #10
0
        /// <summary>
        /// removes item
        /// </summary>
        /// <param name="item">item removed</param>
        public void Remove(IOrderItem item)
        {
            items.Remove(item);
            OnItemPropertyChanged(this, new PropertyChangedEventArgs("Price"));

            if (item is INotifyPropertyChanged notifier)
            {
                notifier.PropertyChanged -= OnItemPropertyChanged;
            }
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SpecialInstructuions"));
        }
Beispiel #11
0
 /// <summary>
 /// Remove an item from the list of items in an order
 /// </summary>
 /// <param name="item"></param>
 public void Remove(IOrderItem item)
 {
     if (items.Contains(item))
     {
         items.Remove(item);
         if (item is INotifyPropertyChanged pcitem)
         {
             pcitem.PropertyChanged -= OnItemChanged;
         }
         PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
         PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
     }
 }
Beispiel #12
0
        /// <summary>
        /// The method that adds for the binding data and updates the items and subtotals
        /// </summary>
        /// <param name="item"></param>
        public void Add(IOrderItem item)
        {
            items.Add(item);

            if (item is INotifyPropertyChanged pcitem) // Don't leave in
            {
                pcitem.PropertyChanged += OnItemChanged;
                //item.PropertyChanged += OnItemChanged; //Implement on every single item and IOrder Item
            }

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
        }
Beispiel #13
0
 /// <summary>
 /// Returns the price of a drink or side based off size
 /// </summary>
 /// <param name="item">Drink or Side</param>
 /// <param name="size">Size of item</param>
 /// <returns>Price of item</returns>
 public static double GetPrice(IOrderItem item, Size size)
 {
     if (item is Side side)
     {
         side.Size = size;
         return(side.Price);
     }
     if (item is Drink drink)
     {
         drink.Size = size;
         return(drink.Price);
     }
     return(0);
 }
Beispiel #14
0
        /// <summary>
        /// Removes the selected item from the order
        /// </summary>
        /// <param name="item"></param>
        public void Remove(IOrderItem item)
        {
            string priceOfItemAsCurrency = String.Format("{0:C}", item.Price);

            itemPrices.Remove(priceOfItemAsCurrency);
            Subtotal -= item.Price;
            items.Remove(item);
            if (item is INotifyPropertyChanged notifier)
            {
                notifier.PropertyChanged -= OnItemPropertyChanged;
            }
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
        }
Beispiel #15
0
 /// <summary>
 /// Returns the calories in a drink or side based off size
 /// </summary>
 /// <param name="item">Drink or Side</param>
 /// <param name="size">Size of item</param>
 /// <returns>Calories in item</returns>
 public static uint GetCalories(IOrderItem item, Size size)
 {
     if (item is Side side)
     {
         side.Size = size;
         return(side.Calories);
     }
     if (item is Drink drink)
     {
         drink.Size = size;
         return(drink.Calories);
     }
     return(0);
 }
Beispiel #16
0
        /// <summary>
        /// removes an item from the order
        /// </summary>
        /// <param name="Item"></param>
        public void Remove(IOrderItem Item)
        {
            items.Remove(Item);
            prices.Remove(Item.Price);

            if (Item is INotifyPropertyChanged)
            {
                Item.PropertyChanged -= onItemChanged;
            }
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Prices"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Instructions"));
        }
Beispiel #17
0
        /// <summary>
        /// This method will remove everything related to the item passed in from the reciept
        /// </summary>
        /// <param name="i">The item needed to be removed to the list</param>
        public void Remove(IOrderItem i)
        {
            /* Do some computation here too to ensure everything is removed */
            double priceOfItem = i.Price;

            Subtotal -= priceOfItem;

            /* Remove the computed values to their respective lists */
            int index = items.IndexOf(i);

            items.Remove(i);
            itemPrices.RemoveAt(index);
            InvokePropertyChanged();
        }
Beispiel #18
0
 /// <summary>
 /// Inspired by Zachary's order helper function, helps change the subtotal
 /// </summary>
 /// <param name="item">item who has a size change.</param>
 public void SubHelp(IOrderItem item, Size size)
 {
     subtotal -= item.Price;
     if (item is Side sid)
     {
         sid.Size  = size;
         subtotal += sid.Price;
     }
     if (item is Drink drin)
     {
         drin.Size = size;
         subtotal += drin.Price;
     }
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
 }
Beispiel #19
0
        /// <summary>
        /// Method to add items to order summary when the buttons are invoked
        /// </summary>
        /// <param name="item"></param>
        public void Add(IOrderItem item)
        {
            items.Add(item);
            priceList.Add(item.Price);

            if (item is INotifyPropertyChanged pcitem)
            {
                pcitem.PropertyChanged += OnItemChanged;
            }                                                                                       // need to do this on every item and iorder interface do not leave this if in code

            SubTotal += item.Price;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Price"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SpecialInstructions"));
        }
Beispiel #20
0
        /// <summary>
        /// Removes and IOrderItem from the order
        /// </summary>
        /// <param name="item"></param>
        public void Remove(IOrderItem item)
        {
            items.Remove(item);

            if (item is INotifyPropertyChanged pcitem)
            {
                pcitem.PropertyChanged -= OnItemChanged;
            }

            Subtotal -= item.Price;
            Total     = Subtotal * 1.16;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Total"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Price"));
        }
Beispiel #21
0
        /// <summary>
        /// Adds the selected item to the order
        /// </summary>
        /// <param name="item"></param>
        public void Add(IOrderItem item)
        {
            items.Add(item);

            //Puts item in currency format to be added to the item prices list (thanks Zachery)
            string priceOfItemAsCurrency = String.Format("{0:C}", item.Price);

            itemPrices.Add(priceOfItemAsCurrency);

            Subtotal += item.Price;
            if (item is INotifyPropertyChanged notifier)
            {
                notifier.PropertyChanged += OnItemPropertyChanged;
            }
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
        }
Beispiel #22
0
 /// <summary>
 /// Removes item from order.
 /// </summary>
 /// <param name="item">Item to remove</param>
 public void Remove(IOrderItem item)
 {
     if (item == null)
     {
         return;
     }
     items.Remove(item);
     if (item is INotifyPropertyChanged pcitem)
     {
         pcitem.PropertyChanged -= OnItemChanged;
     }
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Tax"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Total"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Owed"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("PaidOff"));
 }
Beispiel #23
0
        /// <summary>
        /// Author: Zachary Brunner
        /// This method assists in updating the subtotal for changing sizes
        /// </summary>
        /// <param name="i">The item</param>
        /// <param name="new_size">The size the item is suppose to be</param>
        public void subtotalHelperFunction(IOrderItem i, Size new_size)
        {
            Side  s;
            Drink d;

            subtotal -= i.Price;
            if (i is Side)
            {
                s         = (Side)i;
                s.Size    = new_size;
                subtotal += s.Price;
            }
            else
            {
                d         = (Drink)i;
                d.Size    = new_size;
                subtotal += d.Price;
            }
            InvokePropertyChanged();
        }
Beispiel #24
0
        /// <summary>
        /// Method that gets an IEnumerable of all items.
        /// </summary>
        /// <returns>An IEnumerable containing an instance of each IOrderItem class</returns>
        public static IEnumerable <IOrderItem> CompleteMenu()
        {
            IEnumerable <IOrderItem> menuEnumerable = new IOrderItem[]
            {
                new AngryChicken(),
                new CowpokeChili(),
                new DakotaDoubleBurger(),
                new PecosPulledPork(),
                new RustlersRibs(),
                new TexasTripleBurger(),
                new TrailBurger(),
                new BakedBeans(),
                new ChiliCheeseFries(),
                new CornDodgers(),
                new PanDeCampo(),
                new CowboyCoffee(),
                new JerkedSoda(),
                new TexasTea(),
                new Water()
            };

            return(menuEnumerable);
        }
Beispiel #25
0
        /// <summary>
        /// This method assists in updating the subtotal for changing sizes
        /// *** This method has been implemented from Zachery Burner I did not come up with it ***
        /// </summary>
        /// <param name="i">The item</param>
        /// <param name="new_size">The size the item is suppose to be</param>
        public void subtotalHelperFunction(IOrderItem i, Size new_size)
        {
            Side  s;
            Drink d;

            Subtotal -= i.Price;
            if (i is Side)
            {
                s         = (Side)i;
                s.Size    = new_size;
                Subtotal += s.Price;
            }
            else
            {
                d         = (Drink)i;
                d.Size    = new_size;
                Subtotal += d.Price;
            }
            itemPrices.RemoveAt(itemPrices.Count - 1);

            string priceOfItemAsCurrency = String.Format("{0:C}", i.Price);

            itemPrices.Add(priceOfItemAsCurrency);
        }
Beispiel #26
0
 /// <summary>
 /// Removes the IOrderItem from the list of items
 /// </summary>
 public void Remove(IOrderItem item)
 {
     items.Remove(item);
 }
Beispiel #27
0
 /// <summary>
 /// Add an item to the order
 /// </summary>
 /// <param name="item">Item to add</param>
 public void Add(IOrderItem item)
 {
     items.Add(item);
     ItemChanged(this, new PropertyChangedEventArgs("Price"));
     item.PropertyChanged += ItemChanged;
 }
Beispiel #28
0
 /// <summary>
 /// Remove an item from the order
 /// </summary>
 /// <param name="item">Item to remove</param>
 public void Remove(IOrderItem item)
 {
     items.Remove(item);
     ItemChanged(this, new PropertyChangedEventArgs("Price"));
     item.PropertyChanged -= ItemChanged;
 }
Beispiel #29
0
 /// <summary>
 /// Adds the IOrderItem to the list of items
 /// </summary>
 public void Add(IOrderItem item)
 {
     items.Add(item);
 }
Beispiel #30
0
 /// <summary>
 /// Remove an item from the items list.
 /// </summary>
 /// <param name="item">The item to remove.</param>
 public void Remove(IOrderItem item)
 {
     items.Remove(item);
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
 }