public MainPage() { this.InitializeComponent(); customer_service = new Customer_Service(); Products.ItemsSource = customer_service.GetAllProducts(); Shopping_Cart.ItemsSource = customer_service.GetAllShoppingCartItems(); ShoppingCart_Block.Text = $"Cart {customer_service.Total_Price(Shopping_Cart.ItemsSource as IEnumerable<ShoppingCartItem>):c}"; }
private void Purchase_Click(object sender, RoutedEventArgs e) { // if there's no items ther's nothing to buy if (Shopping_Cart.Items.Count != 0) { //update the cart to nothing and the products to remove the quantity bought customer_service.Update_Products_And_Supply_After_Purchase(Shopping_Cart.ItemsSource as IEnumerable <ShoppingCartItem>); //refresh the listviews Products.ItemsSource = customer_service.GetAllProducts(); Shopping_Cart.ItemsSource = customer_service.GetAllShoppingCartItems(); ShoppingCart_Block.Text = $"Cart {customer_service.Total_Price(Shopping_Cart.ItemsSource as IEnumerable<ShoppingCartItem>):c}"; } }