public IActionResult AccountTransactions(string accountNickname) { var accountTransactions = new AccountTransactionsViewModel() { Nickname = accountNickname }; return(View(accountTransactions)); }
public IActionResult ShowAccount(int accountid, int?amount, int?pagenr) { if (ModelState.IsValid) { var amountFallback = 20; var isAjax = Request.Headers["X-Requested-With"] == "XMLHttpRequest"; var request = new GetAccountByIdRequest() { AccountId = accountid }; var request_transaction = new GetTransactionsByAccountIdRequest() { AccountId = accountid, Amount = amount ?? amountFallback, Offset = (amountFallback * pagenr) ?? 0 }; var query = new GetAccountByIdHandler().Handler(request); var transactions = new GetTransactionsByAccountIdHandler().Handler(request_transaction); if (query != null) { var model = new AccountTransactionsViewModel() { PageNr = pagenr ?? 0, AccountId = accountid, Account = query.Account, Transactions = transactions.Transactions, TotalTransactions = transactions.TotalTransactions, TotalPages = transactions.TotalPages }; if (isAjax) { return(PartialView("_TransactionListPartial", model)); } else { return(View(model)); } } } return(NotFound()); }
public AccountTransactionsViewModel MapAccountTransactionsViewModel(int id) { var transactions = FinancialPlannerRepository.GetTransactions() .Where(m => m.AccountId == id).ToList(); var withdrawalAmount = transactions.Where(m => m.IsWithdrawal).Sum(m => m.Amount); var depositAmount = transactions.Where(m => !m.IsWithdrawal).Sum(m => m.Amount); var transactionTotal = depositAmount - withdrawalAmount; var vm = new AccountTransactionsViewModel { Transactions = SetViewModelsService.SetTransactionViewModels(transactions), TransactionTotal = transactionTotal }; return(vm); }