protected void ShowTransactions(int page = 1)
        {
            Console.Clear();
            Console.WriteLine($"Transactions: {User.Username}\n");
            var transactions = UserTransactionService.GetTransactionsForUser(User.Id, page);
            var table        = new ConsoleTable("Date", "Type", "Amount", "Balance");

            foreach (var trans in transactions)
            {
                table.AddRow($"{trans.Date:MM/dd/yyyy hh:mm:ss tt}", $"{trans.GetTransactionType().ToString()}", $"{trans.Amount:C}", $"{trans.CurrentBalance:C}");
            }
            table.Write();
            Console.WriteLine($" Current Page: {page}");
            Console.WriteLine("1. Next Page\t2. Prev Page\t3. Account Screen");

            if (Int32.TryParse(Console.ReadLine(), out int input))
            {
                switch (input)
                {
                case 1:
                {
                    ShowTransactions(++page);
                    break;
                }

                case 2:
                {
                    if (page > 1)
                    {
                        ShowTransactions(--page);
                    }
                    else
                    {
                        ShowTransactions(1);
                    }
                    break;
                }

                case 3:
                {
                    new AccountScreen(User.Id, AuthKey).Run();
                    break;
                }

                default:
                {
                    ShowInvalidOptionError();
                    break;
                }
                }
            }
            else
            {
                ShowInvalidOptionError();
            }
        }
Esempio n. 2
0
        public void Deposit_WithValidAmount_AddedToTransactionList()
        {
            //Arrange
            var user = new User
            {
                Username  = "******",
                FirstName = "Demo",
                LastName  = "User",
                Password  = "******"
            };

            new AuthService().Register(user);
            UserTransactionService transactionService = new UserTransactionService();

            //act
            transactionService.Deposit(user.Id, 5);

            //Assert
            var allTransactions = transactionService.GetTransactionsForUser(user.Id);

            Assert.IsTrue(allTransactions.Count() > 0, "Wrong transaction list count");
        }