Esempio n. 1
0
        /// <summary>
        /// Adds the specified product to cart
        /// </summary>
        /// <param name="productViewModel">The view model of the product row viewer to add product</param>
        public void AddToCart(ProductRowViewerViewModel productViewModel)
        {
            var viewModel = new OrderRowViewerViewModel
                            (
                CurrentCart.Count + 1,
                Order.CurrentOrder.ID,
                "1",
                "0",
                productViewModel
                            );

            viewModel.CanDelete = true;

            // Updates the list price
            viewModel.TotalPriceChanged += () => OnPropertyChanged(nameof(TotalPrice));
            viewModel.Deleted           += DeleteItem;

            if (!mIsSearching)
            {
                CurrentCart.Add(viewModel);
                Items.Add(viewModel);
            }
            else
            {
                CurrentCart.Add(viewModel);
            }

            // Make the product not available to be added to the cart again
            // Because the qunatity of the product can be specified in the (CartPage)
            productViewModel.IsOutFromCart = false;

            OnPropertyChanged(nameof(TotalPrice));
        }