Example #1
0
        public IActionResult GetTransactions()
        {
            int     currentUserId = int.Parse(LoggedInUser);
            User    payee, recipient;
            Account currentAccount = _accountService.GetAccountOfUser(currentUserId);

            if (currentAccount != null)
            {
                List <AccountTransaction> transactions = _accountTransactionService.GetTransactionsForAccount(currentAccount);

                if (transactions.Count > 0)
                {
                    List <AccountTransactionsForUser> ListOfTransactionModel = new List <AccountTransactionsForUser>();
                    foreach (AccountTransaction transaction in transactions)
                    {
                        payee     = _userService.GetUserById(_accountService.GetAccountById(transaction.PayeeId).UserId);
                        recipient = _userService.GetUserById(_accountService.GetAccountById(transaction.RecipientId).UserId);

                        ListOfTransactionModel.Add(_accountService.GetModelAccountTransactionsForUser(transaction, payee, recipient, currentUserId));
                    }

                    return(Ok(ListOfTransactionModel));
                }
                else
                {
                    return(NotFound());
                }
            }
            else
            {
                return(NotFound());
            }
        }