private AccountDetailsViewModel FindAccount(string acctId) { AccountDetailsViewModel details = default(AccountDetailsViewModel); var item = acctList.ToLookup(s => s.AccountId == acctId); foreach (var i in item[true]) { details = i; } return(details); }
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListView list = sender as ListView; if (list != null) { int idx = list.SelectedIndex; AccountDetailsViewModel details = acctList[idx]; Vm.AccountId = details.AccountId; Vm.AccountName = details.AccountName; Vm.Balance = details.Balance; Vm.Type = details.Type; } }
private void DepositBtn_Click(object sender, RoutedEventArgs e) { int idx = listView.SelectedIndex; if (idx >= 0) { AccountDetailsViewModel details = acctList[idx]; TxDataGetter getter = new TxDataGetter(); Transaction tx = new Transaction(); tx.acctLastName = details.AccountName; tx.acctId = Convert.ToInt32(details.AccountId); tx.acctType = details.Type; tx.balance = details.Balance; tx.txAmount = (float)Convert.ToDouble(depositTextBox.Text); tx.txOperation = "deposit"; BankClient.TcpClient().SetData(tx, getter); } }
private void AddData(MessageData data) { System.Diagnostics.Debug.WriteLine("Processing Message Type: {0}", data.id); if ((data == null) || (data.id <= 0) || (data.message == null)) { return; } switch (data.id) { case MessageTypes.AccountDetailsMsgType: break; case MessageTypes.AccountListMsgType: break; case MessageTypes.ClientIdMsgType: break; case MessageTypes.OpenAcctMsgType: break; case MessageTypes.TxMsgType: { Transaction tx = data.message as Transaction; if (tx != null) { switch (tx.txOperation) { case "open-response": { AccountDetailsViewModel details = new AccountDetailsViewModel(); details.AccountId = tx.acctId.ToString(); details.AccountName = tx.acctLastName; details.Balance = tx.balance; details.Type = tx.acctType; acctList.Add(details); } break; case "deposit-response": { AccountDetailsViewModel details = FindAccount(tx.acctId.ToString()); if (details != default(AccountDetailsViewModel)) { details.Balance = tx.balance; } } break; case "withdraw-response": { AccountDetailsViewModel details = FindAccount(tx.acctId.ToString()); if (details != default(AccountDetailsViewModel)) { details.Balance = tx.balance; } } break; default: System.Diagnostics.Debug.WriteLine("Unsupported Transaction Type: {0}", tx.txOperation); break; } } } break; default: System.Diagnostics.Debug.WriteLine("Unsupported Msg Type {0}", data.id); break; } }