private async void myCloseAccount_Click(object sender, RoutedEventArgs e) { if (accountList.SelectedItem != null) { MessageDialog msg = new MessageDialog("Remove account permanently?", "Remove account"); msg.Commands.Clear(); msg.Commands.Add(new UICommand { Label = "Yes", Id = 0 }); msg.Commands.Add(new UICommand { Label = "Cancel", Id = 1 }); var result = await msg.ShowAsync(); if ((int)result.Id == 0) { string rate = AccountLogic.PrintAccountInfo((Account)accountList.SelectedItem); customer.Accounts.Remove((Account)accountList.SelectedItem); MessageDialog msg2 = new MessageDialog(rate, "Deleted account information"); await msg2.ShowAsync(); } } }
/// <summary> /// Prints the account information upon removal. /// </summary> public static string RemoveCustomer(Customer customer) { string removedCustomer = "Accounts removed: \n"; try { foreach (var item in customer.Accounts) { removedCustomer += AccountLogic.PrintAccountInfo(item) + "\n"; } Customers.Remove(customer); } catch (Exception) { } return(removedCustomer); }