private async void borrowReturnBTN_Click(object sender, RoutedEventArgs e) { Object selectedItem = allItemsListView.SelectedItem; if (selectedItem != null) { MessageDialog msg = new MessageDialog("Are you sure to borrow or return this item?"); msg.Commands.Add(new UICommand("Yes")); msg.Commands.Add(new UICommand("No")); IUICommand selectedCommand = await msg.ShowAsync(); if (selectedCommand.Label == "Yes") { logicsData.SelectedItem = (AbstractItem)allItemsListView.SelectedItem; if ((logicsData.SelectedItem).IsBorrowed == false) { logicsData.BorrowItem((AbstractItem)allItemsListView.SelectedItem); } else { logicsData.ReturnItem((AbstractItem)allItemsListView.SelectedItem); } allItemsListView.ItemsSource = logicsData.GetAllLibraryItems(); } } else { await new MessageDialog("Please select an item to borrow or return!", "No item selected").ShowAsync(); } }
private void btnBorrowItem_Click(object sender, RoutedEventArgs e) { AbstractItem currentItem = GetItemFromSender(sender); if (currentItem.IsBorrowed) { logicsData.ReturnItem(currentItem); } else { logicsData.BorrowItem(currentItem); } InvokeItemDetails(); }