private void FillWithDummyData() { FullPrice = "$100.50"; TotalDiscount = "$10.50"; TotalPrice = "$90.00"; ShoppingCartItemViewModels = new ObservableCollection<ShoppingCartItemViewModel>() { new ShoppingCartItemViewModel(new ShoppingCartItem() { Id = Guid.NewGuid().ToString(), Product = new Product() { Title = "Product 1", Description = "Description of Product 1", ListPrice = 25.10, ProductNumber = "1", ImageUri = new Uri("ms-appx:///Assets/StoreLogo.png")}, Quantity = 1, Currency = "USD" }), new ShoppingCartItemViewModel(new ShoppingCartItem() { Id = Guid.NewGuid().ToString(), Product = new Product() { Title = "Product 2", Description = "Description of Product 2", ListPrice = 25.10, ProductNumber = "2", ImageUri = new Uri("ms-appx:///Assets/StoreLogo.png")}, Quantity = 20, Currency = "USD" }), new ShoppingCartItemViewModel(new ShoppingCartItem() { Id = Guid.NewGuid().ToString(), Product = new Product() { Title = "Product 3", Description = "Description of Product 3", ListPrice = 25.10, ProductNumber = "3", ImageUri = new Uri("ms-appx:///Assets/StoreLogo.png")}, Quantity = 30, Currency = "USD" }), new ShoppingCartItemViewModel(new ShoppingCartItem() { Id = Guid.NewGuid().ToString(), Product = new Product() { Title = "Product 4", Description = "Description of Product 4", ListPrice = 25.10, ProductNumber = "4", ImageUri = new Uri("ms-appx:///Assets/StoreLogo.png")}, Quantity = 14, Currency = "USD" }), new ShoppingCartItemViewModel(new ShoppingCartItem() { Id = Guid.NewGuid().ToString(), Product = new Product() { Title = "Product 5", Description = "Description of Product 5", ListPrice = 25.10, ProductNumber = "5", ImageUri = new Uri("ms-appx:///Assets/StoreLogo.png")}, Quantity = 25, Currency = "USD" }), }; SelectedItem = ShoppingCartItemViewModels[0]; }
private async Task Remove(ShoppingCartItemViewModel item) { if (item != null) { await _shoppingCartRepository.RemoveShoppingCartItemAsync(item.Id); } ShoppingCartItemViewModels.Remove(item); CheckoutCommand.RaiseCanExecuteChanged(); OnPropertyChanged("FullPrice"); OnPropertyChanged("TotalDiscount"); OnPropertyChanged("TotalPrice"); }
public async void UpdateShoppingCartAsync(object notUsed) { _shoppingCart = await _shoppingCartRepository.GetShoppingCartAsync(); if (_shoppingCart != null && _shoppingCart.ShoppingCartItems != null) { ShoppingCartItemViewModels = new ObservableCollection<ShoppingCartItemViewModel>(); foreach (var item in _shoppingCart.ShoppingCartItems) { var shoppingCartItemViewModel = new ShoppingCartItemViewModel(item); shoppingCartItemViewModel.PropertyChanged += shoppingCartItemViewModel_PropertyChanged; ShoppingCartItemViewModels.Add(shoppingCartItemViewModel); } CheckoutCommand.RaiseCanExecuteChanged(); OnPropertyChanged("FullPrice"); OnPropertyChanged("TotalDiscount"); OnPropertyChanged("TotalPrice"); } }