Beispiel #1
0
        /// <summary>
        /// Removes the product from the cart
        /// </summary>
        /// <param name="viewModel">The view model of the product row viewer to remove the product</param>
        public void RemoveFromCart(ProductRowViewerViewModel viewModel)
        {
            // Removing it from the (Items) list if there is no searching now
            if (!mIsSearching)
            {
                foreach (OrderRowViewerViewModel item in Items)
                {
                    if (item.ProductViewModel.Equals(viewModel))
                    {
                        Items.Remove(item);
                        break;
                    }
                }
            }

            // Removing it from the cart
            foreach (OrderRowViewerViewModel item in CurrentCart)
            {
                if (item.ProductViewModel.Equals(viewModel))
                {
                    CurrentCart.Remove(item);
                    break;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Deletes the specified item from the list
        /// </summary>
        /// <param name="viewModel">The view model of the item to delete</param>
        protected override void DeleteItem(BaseRowViewerViewModel viewModel)
        {
            OrderRowViewerViewModel vm = viewModel as OrderRowViewerViewModel;

            // Delete from the items list
            Items.Remove(viewModel);
            CurrentCart.Remove(viewModel);
            vm.ProductViewModel.IsOutFromCart = true;
            for (int i = ((OrderRowViewerViewModel)viewModel).RowNumber - 1; i < Items.Count; i++)
            {
                ((OrderRowViewerViewModel)Items[i]).RowNumber--;
            }
            OnPropertyChanged(nameof(TotalPrice));
        }