private void DeauthorizeBankAccounts() { foreach (Institution bank in bankAccountsToDeauthorize) { PlaidInterface.DeauthorizeInstitution(bank); } }
private void PopulateAccounts() { comboBoxAccounts.Items.Clear(); comboBoxAccounts.Items.Add("All accounts"); if (comboBoxBanks.SelectedItem.ToString() == "All banks") { foreach (Institution bank in Settings.GetCurrentInstitutions()) { List <Account> accountsForBank = PlaidInterface.GetInstitutionAccounts(bank); bank.Accounts = accountsForBank; foreach (Account account in accountsForBank) { comboBoxAccounts.Items.Add(account); } } } else { Institution selectedBank = (Institution)comboBoxBanks.SelectedItem; List <Account> accounts = PlaidInterface.GetInstitutionAccounts(selectedBank); selectedBank.Accounts = accounts; foreach (Account account in accounts) { comboBoxAccounts.Items.Add(account); } } comboBoxAccounts.SelectedIndex = 0; }
private void PopulateTransactions() { transactionsToDisplay = new List <Transaction>(); if (comboBoxAccounts.Items.Count == 0) { MessageBox.Show("Click \"Get Accounts\" first"); return; } if (comboBoxAccounts.SelectedItem.ToString() == "All accounts") { if (comboBoxBanks.SelectedItem.ToString() == "All banks") { foreach (Institution bank in Settings.GetCurrentInstitutions()) { List <Transaction> transactionsForBank = PlaidInterface.GetTransactions(bank, dateTimePickerStart.Value, dateTimePickerEnd.Value); PlaidInterface.AddTransactionsToAccounts(bank.Accounts, transactionsForBank); transactionsToDisplay.AddRange(transactionsForBank); } } else { Institution selectedBank = (Institution)comboBoxBanks.SelectedItem; List <Transaction> transactionsForBank = PlaidInterface.GetTransactions(selectedBank, dateTimePickerStart.Value, dateTimePickerEnd.Value); PlaidInterface.AddTransactionsToAccounts(selectedBank.Accounts, transactionsForBank); transactionsToDisplay.AddRange(transactionsForBank); } } else { Account selectedAccount = (Account)comboBoxAccounts.SelectedItem; Institution bankHoldingAccount = Settings.GetCurrentInstitutions().Find(p => p.Accounts.Find(a => a.Id == selectedAccount.Id) != null); comboBoxBanks.SelectedItem = bankHoldingAccount; List <Transaction> transactionsForBank = PlaidInterface.GetTransactions(bankHoldingAccount, dateTimePickerStart.Value, dateTimePickerEnd.Value); PlaidInterface.AddTransactionsToAccounts(bankHoldingAccount.Accounts, transactionsForBank); transactionsToDisplay.AddRange(selectedAccount.RecentTransactions); } if ((string)comboBoxSortDirection.SelectedItem == "Ascending") { transactionsToDisplay.Sort((a, b) => a.Date.CompareTo(b.Date)); } else { transactionsToDisplay.Sort((a, b) => b.Date.CompareTo(a.Date)); } DisplayTransactions(); }
private void buttonAddBankAccount_Click(object sender, EventArgs e) { PlaidInterface.StartPlaidLink(); textBoxPublicToken.Text = ""; textBoxInstitutionId.Text = ""; labelInstitutionId.Visible = true; textBoxInstitutionId.Visible = true; labelPublicToken.Visible = true; textBoxPublicToken.Visible = true; buttonAuthorize.Visible = true; }
private void listBoxBankAccounts_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { int index = this.listBoxBankAccounts.IndexFromPoint(new Point(e.X, e.Y)); if (index < 0) { return; } this.listBoxBankAccounts.SelectedIndex = index; ContextMenu removeMenu = new ContextMenu(); MenuItem updateItem = new MenuItem() { Text = "Update" }; updateItem.Click += (s, args) => { PlaidInterface.RefreshToken(((Institution)listBoxBankAccounts.Items[index]).Credentials.AccessToken); }; removeMenu.MenuItems.Add(updateItem); MenuItem removeItem = new MenuItem() { Text = "Remove" }; removeItem.Click += (s, args) => { bankAccountsToDeauthorize.Add((Institution)listBoxBankAccounts.Items[index]); if ((Enums.Environment)comboBoxPlaidEnvironments.SelectedItem == Enums.Environment.Sandbox) { sandboxInstitutions.RemoveAt(index); } else { developmentInstitutions.RemoveAt(index); } SyncListBox(); }; removeMenu.MenuItems.Add(removeItem); removeMenu.Show((sender as ListBox), new Point(e.X, e.Y)); } }
private void buttonAuthorize_Click(object sender, EventArgs e) { Institution bank = PlaidInterface.GetInstitutionById(textBoxInstitutionId.Text); bank.Credentials = PlaidInterface.AuthorizeInstitution(bank, textBoxPublicToken.Text); if ((Enums.Environment)comboBoxPlaidEnvironments.SelectedItem == Enums.Environment.Sandbox) { sandboxInstitutions.Add(bank); } else { developmentInstitutions.Add(bank); } SyncListBox(); labelInstitutionId.Visible = false; textBoxInstitutionId.Visible = false; labelPublicToken.Visible = false; textBoxPublicToken.Visible = false; buttonAuthorize.Visible = false; }