public IActionResult Index() { string userId = userManager.GetUserId(User); try { var customer = customerService.GetCustomerFromUserId(userId); List <BankAccountViewModel> accountViewApplicationLogic = new List <BankAccountViewModel>(); foreach (var bankAccount in customer.BankAccounts) { accountViewApplicationLogic.Add(new BankAccountViewModel { BankAccount = bankAccount }); } AccountsListViewModel viewModel = new AccountsListViewModel() { BankAccounts = accountViewApplicationLogic, CustomerName = $"{customer.FirstName} {customer.LastName}", PhoneNo = customer.ContactDetails?.PhoneNo }; return(View(viewModel)); } catch (Exception e) { //log exception return(BadRequest("Unable retrieve data for the current user")); } }
public async Task <IActionResult> Index(AccountsQuery query, CancellationToken cancellationToken) { var queryable = MailAppDbContext.Accounts .Where(x => String.IsNullOrEmpty(query.Nick) || x.Nick.Contains(query.Nick)) .Where(x => String.IsNullOrEmpty(query.Email) || x.Email.Contains(query.Email)); queryable = query.Sort switch { AccountsQuery.SortingOptions.Email => queryable.OrderBy(x => x.Email), AccountsQuery.SortingOptions.Nick => queryable.OrderBy(x => x.Nick), _ => queryable }; var accounts = await queryable .Select(x => new AccountViewModel(x)) .ToArrayAsync(cancellationToken); var viewModel = new AccountsListViewModel { Email = query.Email, Nick = query.Nick, Accounts = accounts }; return(View("List", viewModel)); } }
public ActionResult ViewAccountList() { JsonDeserializer deserialize = new JsonDeserializer(); var client = new RestClient("http://localhost:4000/api/accountsAll"); var request = new RestRequest(Method.GET); var response = client.Execute <List <Role> >(request); List <Account> accounts = deserialize.Deserialize <List <Account> >(response); AccountsListViewModel model = new AccountsListViewModel(accounts); return(View(model)); }
public App() { InitializeComponent(); var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); var path = Path.Combine(documentsPath, "settings.json"); try { var item = JsonConvert.DeserializeObject <SettingsItem>(File.ReadAllText(path)); CurrentSettings = new SettingsViewModel(item.Language, item.IsDarkMode); } catch { CurrentSettings = new SettingsViewModel("RU", false); } Accounts = new AccountsListViewModel(); MainPage = new SearchPage(); }
public AccountsList() { InitializeComponent(); DataContext = new AccountsListViewModel(); }