public void CheckBalance() { BankingContext bankingContext = GetContext <BankingContext>(); String account = bankingContext.GetOptional <String> ("account"); //Check balance of all the accounts if (account == null) { IList <BalanceInfo> balances = new List <BalanceInfo> (); BalanceInfo balance1 = new BalanceInfo { Balance = bankingContext.GetBalance("100021"), Account = "100021" }; BalanceInfo balance2 = new BalanceInfo { Balance = bankingContext.GetBalance("100023"), Account = "100023" }; balances.Add(balance1); balances.Add(balance2); bankingContext.Set("balance", balances); return; } //Balance of one single account if (!bankingContext.AccountExists(account)) { bankingContext.Fail("INEXISTENT_ACCOUNT"); //Exit with error } bankingContext.Set("balance", bankingContext.GetBalance(account)); }
private String balanceInfoToString(BalanceInfo balanceInfo) { return(String.Format("{0} - {1}", balanceInfo.Account, balanceInfo.Balance.ToString("C"))); }