Exemplo n.º 1
0
        /// <summary>
        /// Fetch and display user account balances
        /// </summary>
        static async Task DisplayAccountBalancesAsync(IBankingConnector bankConnector)
        {
            BankingResult <List <Account> > accounts = await bankConnector.GetAccountsAsync();

            if (accounts.GetStatus() == ResultStatus.DONE)
            {
                Console.WriteLine("Listing user accounts...");

                foreach (Account account in accounts.GetData())
                {
                    Console.WriteLine($"Account {account.Iban}");

                    BankingResult <List <Balance> > resultBalances = await bankConnector.GetBalancesAsync(account.Id);

                    if (resultBalances.GetStatus() == ResultStatus.DONE)
                    {
                        List <Balance> accountBalances = resultBalances.GetData();
                        foreach (Balance balance in accountBalances)
                        {
                            Console.WriteLine($"- {balance.BalanceType}: {balance.BalanceAmount.Currency}{balance.BalanceAmount.Amount} ({balance.ReferenceDate:ddMMMyyyy})");
                        }
                    }
                }
            }
        }