private void BuyBtnClick(object sender, RoutedEventArgs e) { int index = ProductList.SelectedIndex; if (index < 0) { return; } StockItem item = productItems.ElementAt(index); if (item != null) { productService.BuyProduct(item.Name, username, out bool bought, out bool bought2); Debug.Content = bought ? "Product bought" : "Couldn't buy product"; if (bought) { userService.AddProduct(username, item.Name); RefreshScreen(); } } }