public async Task ShowBalance(IDialogContext context, LuisResult result) { PostbankClient client = new PostbankClient("Hackathon5", "test12345"); try { client = await client.GetAccountInformationAsnyc(); EntityRecommendation ent = null; if (result.TryFindEntity("AccountNumber", out ent)) { var account = client.IDInfo.accounts.Where(i => i.iban.ToLower() == ent.Entity).First(); await context.PostAsync($"The balance for your {account.productDescription} account with IBAN {account.iban} is {account.amount} {account.currency}."); } else { await context.PostAsync($"For what account do you want to display your balance? You have got {client.IDInfo.accounts.Count} account(s) with the following IBAN:"); foreach (var item in client.IDInfo.accounts) { await context.PostAsync(item.iban); } await context.PostAsync("Which account do you want to use?"); } } catch (Exception ex) { await context.PostAsync($"I am sorry. :( There has been some problems in getting your account information. Please try again later. The error message is {ex.Message}."); } finally { context.Wait(MessageReceived); } }
public async Task ShowTransactions(IDialogContext context, LuisResult result) { PostbankClient client = new PostbankClient("Hackathon5", "test12345"); try { client = await client.GetAccountInformationAsnyc(); EntityRecommendation accountNumber = null; EntityRecommendation amount = null; result.TryFindEntity("AccountNumber", out accountNumber); result.TryFindEntity("builtin.number", out amount); if (accountNumber != null && amount != null) { var account = client.IDInfo.accounts.Where(i => i.iban.ToLower() == accountNumber.Entity).First(); var amountNumber = int.Parse(amount.Entity); var transactions = await client.GetTransactionForAccount(account); await context.PostAsync($"The balance for your {account.productDescription} account with IBAN {account.iban} is {account.amount} {account.currency}. These are the last {amount.Entity} transactions:"); for (int i = 0; i < amountNumber; i++) { if (transactions.content[i] != null) { var currentTrans = transactions.content[i]; await context.PostAsync($"{DateTime.FromFileTime(currentTrans.valutaDate)} {currentTrans.transactionType}: {currentTrans.amount} {currentTrans.currency} {String.Join("", currentTrans.purpose)}"); } } } else { await context.PostAsync($"For which account do you want to display your transaction? You have got {client.IDInfo.accounts.Count} account(s) with the following IBAN:"); foreach (var item in client.IDInfo.accounts) { await context.PostAsync(item.iban); } await context.PostAsync("Which account do you want to use? Please state the IBAN and the number of transactions you want to see."); } } catch (Exception ex) { await context.PostAsync($"I am sorry. :( There has been some problems in getting your account information. Please try again later. The error message is {ex.Message}."); } finally { context.Wait(MessageReceived); } }
// GET: api/Test/5 public async Task <string> Get(int id) { try { client = new PostbankClient("Hackathon5", "test12345"); client = await client.GetAccountInformationAsnyc(); return(client.Username); } catch (Exception e) { throw; return(e.Message); } }
// GET: api/Test public async Task <PostbankAccount> Get() { //return new string[] { "value1", "value2" }; client = new PostbankClient("Hackathon5", "test12345"); client = await client.GetAccountInformationAsnyc(); if (client != null) { return(client.IDInfo.accounts[0]); } else { return(null); } }