public async Task GetAccountDetails(string userToken) { try { OmniDataItemAPI injector = new OmniDataItemAPI(_WebAPIURL); RootAccounts rootAccount = await injector.GetAccountsFromAPI(userToken); List <SelectListItem> items = new List <SelectListItem>(); if (rootAccount != null && rootAccount.Status == 0) { foreach (var card in rootAccount.CardList) { foreach (var account in card.AccountList) { var AccountIDEncrypted = OmniDataManagement.Helpers.StringCipher.Encrypt(account.AccountID.ToString(), OmniDataManagement.Constants.PassPhrase); AccountDetailsNameValue.Add(account.AccountID, account.AccountAlias); items.Add(new SelectListItem() { Text = account.AccountAlias, Value = AccountIDEncrypted }); } } } ViewBag.AccountDetails = new SelectList(items, "Value", "Text"); } catch (Exception ex) { await AddToErrorLog(userToken, "MyTransactions", ex.Message); } }
// GET: AccountDetails public async Task <ActionResult> Index() { if (!await AuthorizePage("MyAccount")) { return(RedirectToAction("NoAccess", "Home")); } LoginResponseDetails userLoginDetails = GetUserLoginDetails(); try { if (userLoginDetails != null) { OmniDataItemAPI injector = new OmniDataItemAPI(_WebAPIURL); RootAccounts rootAccount = await injector.GetAccountsFromAPI(userLoginDetails.Token); if (rootAccount != null && rootAccount.Status == 0) { List <CardAccountDetails> cardAccountDetails = new List <CardAccountDetails>(); foreach (var card in rootAccount.CardList) { CardAccountDetails cardEntity = new CardAccountDetails(); cardEntity.CardID = card.CardID; cardEntity.CardName = card.CardName; cardEntity.CardStatus = card.CardStatus; cardEntity.AccountList = new List <AccountDetails>(); foreach (var account in card.AccountList) { AccountDetails entity = new AccountDetails(); entity.AccountID = account.AccountID; entity.AccountAlias = account.AccountAlias; entity.AccountName = account.AccountName; entity.AccountStatus = account.AccountStatus; entity.AccountType = account.AccountType; entity.AccountTypeName = Constants.GetAccountType(account.AccountType); entity.AccountIDEncrypted = OmniDataManagement.Helpers.StringCipher.Encrypt(account.AccountID.ToString(), OmniDataManagement.Constants.PassPhrase); cardEntity.AccountList.Add(entity); } cardAccountDetails.Add(cardEntity); } return(View(cardAccountDetails)); } } } catch (Exception ex) { await AddToErrorLog(userLoginDetails.Token, "MyAccount", ex.Message); return(View()); } return(View()); }