private void OnDecreaseQuantity()
 {
     if (SelectedOrderItem == null)
     {
         MessageBox.Show("Select item to decrease quantity");
         return;
     }
     //Check if the product was already selected
     if (OrderItems.Any(p => p.UPCCode == SelectedOrderItem.UPCCode))
     {
         if (OrderItems.First(p => p.UPCCode == SelectedOrderItem.UPCCode).Quantity <= 1)
         {
             if (SelectedOrderItem != null)
             {
                 MessageBoxResult result = MessageBox.Show("You are about to delete an item. Do you want to continue?", "Delete Item", MessageBoxButton.YesNo, MessageBoxImage.Question);
                 if (result == MessageBoxResult.Yes)
                 {
                     OrderItems.Remove(SelectedOrderItem);
                 }
                 ;
             }
         }
         else
         {
             OrderItems.First(p => p.UPCCode == SelectedOrderItem.UPCCode).Quantity -= 1;
             RaisePropertyChanged("OrderSubTotal");
             RaisePropertyChanged("OrderTax");
             RaisePropertyChanged("BalanceDue");
         }
     }
 }
示例#2
0
    // Other stuff
    public void RemoveOrderItem(int orderItemId)
    {
        var orderItemToRemove = OrderItems.First(oi => oi.Id == orderItemId)
                                OrderItems.Remove(orderItemToRemove);

        DomainEvents.Raise(new OrderItemRemoved(orderItemToRemove));
    }
示例#3
0
        /// <summary>
        /// First init
        /// </summary>
        private void Init()
        {
            // Set VM to this
            VM = this;

            // Get the current dispatcher
            this.ThisDispatcher = Dispatcher.CurrentDispatcher;

            // Skip if the list is empy
            if (DatabaseHelpers.AllProducts != null)
            {
                // Load products from the Database class
                PagedProducts = new ThreadSafeObservableCollection <OrderItemViewModel>(
                    DatabaseHelpers.AllProducts.Where(
                        p => p.Type == CurrentMenu));
            }
            else
            {
                throw new Exception("List is null");
            }

            /// <summary>
            /// Create all commands associated with
            /// this View
            /// </summary>
            #region Create Commands
            // Create the command for the category buttons
            CategorySelectCommand = new RelayCommand(CategoryChanged);
            // Create the command for the Add Product buttons
            AddProductCommand = new RelayCommand(AddProduct);
            // Create the command for 'RemoveProduct' buttons
            RemoveProductCommand = new RelayCommand((o) => { OrderItems.Remove(OrderItems.First(i => i.BasketID.Equals((int)o))); });
            // Create the command for the 'Cancel' button
            CancelCommand = new RelayCommand((o) => { MainWindowViewModel.VM.CurrentScreen = MainPages.WellcomeScreen; });
            // Create the command for the 'Cancel' button
            PayCommand = new RelayCommand((o) => { SubPage = OrderSubPages.PaymentPage; });
            // Create the command for the 'Edit' buttons
            EditObjectCommand = new RelayCommand((o) => { SelectedItem = OrderItems.First(i => i.BasketID.Equals((int)o)).Copy();
                                                          SubPage      = OrderSubPages.EditObjectPage; });
            #endregion

            // Set the first food menu
            CurrentMenu = Enums.Extra;
            // Reset the static properties for the order
            OrderItems = new ObservableCollection <OrderItemViewModel>();
            // Create the event for the collection
            OrderItems.CollectionChanged += OrderItems_CollectionChanged;
            // Call it once to set price string to '0'
            OrderItems_CollectionChanged(null, null);
        }
示例#4
0
文件: Order.cs 项目: DarkFM/BookMania
        public void AddOrderItem(Book book, int quantity, decimal price)
        {
            if (!OrderItems.Any(oi => oi.BookOrdered.BookId == book.Id))
            {
                _orderItems.Add(new OrderItem(
                                    quantity,
                                    price,
                                    new BookItemSnapshot(book.Id, book.Title, book.ImageUrl))
                                );
                return;
            }
            var existingItem = OrderItems.First(oi => oi.BookOrdered.BookId == book.Id);

            existingItem.Quantity += quantity;
        }
 private void ReceiveMessage(Product product)
 {
     //Check if the product was already selected
     if (OrderItems.Any(p => p.UPCCode == product.UPCCode))
     {
         OrderItems.First(p => p.UPCCode == product.UPCCode).Quantity += 1;
         RaisePropertyChanged("OrderSubTotal");
         RaisePropertyChanged("OrderTax");
         RaisePropertyChanged("BalanceDue");
     }
     else
     {
         OrderItems.Add(new POS_DataLibrary.OrderItems
         {
             UPCCode      = product.UPCCode,
             CategoryName = product.CategoryName.ToString(),
             CategoryId   = product.CategoryId,
             Quantity     = 1,
             Price        = product.Price,
             Name         = product.Name
         });
     }
 }
示例#6
0
 public OrderItem GetOrderItemBySku(string sku) => OrderItems.First(oi => string.Equals(oi.ProductOption.Sku.ToUpper(), sku.ToUpper()));