Пример #1
0
        public void GetAccountById()
        {
            IBankService bankService = ServiceProvider.GetService <IBankService>();
            Account      account     = CreateTestAccount("username", "password");

            bankService.CreateAccount(account);
            Account account2 = CreateTestAccount("usernameone", "passwordtwo");

            bankService.CreateAccount(account2);

            Account actualAccountOne = bankService.GetAccount(account.AccountId);
            Account actualAccounTwo  = bankService.GetAccount(account2.AccountId);

            Assert.Equal(account, actualAccountOne);
            Assert.Equal(account2, actualAccounTwo);
        }
Пример #2
0
        public async Task <IActionResult> Account([FromBody] GetAccountRequest request)
        {
            var conta = await bankService.GetAccount(request);

            if (conta is null)
            {
                return(NotFound());
            }
            return(Ok(conta));
        }
Пример #3
0
 public ActionResult Details(string id)
 {
     if (id == null)
     {
         return(HttpNotFound());
     }
     try
     {
         return(View(_service.GetAccount(id)));
     }
     catch (Exception e)
     {
         _log.Error("Error getting account details: ", e);
         throw;
     }
 }
Пример #4
0
        public ActionResult <Account> ViewAccountInformation(int id)
        {
            var accountFound = _bankService.GetAccount(id);

            if (accountFound == null)
            {
                return(NotFound());
            }

            return(accountFound);
        }
Пример #5
0
        public void TestCreateAccount()
        {
            IBankService bankService = ServiceProvider.GetService <IBankService>();

            // Create test account and add to the service
            Account account = CreateTestAccount("username", "password");

            bankService.CreateAccount(account);

            // verify that the account was added.
            Assert.Equal(account, bankService.GetAccount(account.AccountId));
        }
Пример #6
0
        static void Main(string[] args)
        {
            // Start up and create defaults.
            IBankService bankService = StartUp.GetConfiguredServices();

            StartUp.CreatePreconfiguredAccounts(bankService);
            string username;
            string password;

            // Welcome message.
            DisplayMessaging.WelcomeMessage();
            string createOrNot = Console.ReadLine().ToLower();

            if (createOrNot.Equals("create"))
            {
                Account newAccount = null;
                while (newAccount == null)
                {
                    newAccount = DisplayMessaging.CreateNewAccountFromUser(bankService);
                }
            }

            // User selection and interactions.
            Selections convertedInput;

            while (true)
            {
                // User must log into an account first.
                Console.WriteLine("Please log into an account");
                Console.WriteLine("Enter username: "******"Enter password: "******"Amount to withdraw from account: ");
                        input = Console.ReadLine();
                        while (!Int32.TryParse(input, out intValue))
                        {
                            Console.WriteLine("Not a valid number to deposit");
                            Console.WriteLine("Amount to withdraw from account: ");
                            input = Console.ReadLine();
                        }
                        Transactions transactionWithdraw = HelperFunctions.CreateTransaction((int)userKey, intValue, "Withdraw");
                        bankService.WithdrawlFromAccount((int)userKey, transactionWithdraw);
                        break;

                    case Selections.DepositIntoAccount:
                        Console.WriteLine("Amount to deposit into account: ");
                        input = Console.ReadLine();
                        while (!Int32.TryParse(input, out intValue))
                        {
                            Console.WriteLine("Not a valid number to deposit");
                            Console.WriteLine("Amount to deposit into account: ");
                            input = Console.ReadLine();
                        }
                        Transactions transactionDeposit = HelperFunctions.CreateTransaction((int)userKey, intValue, "Deposit");
                        bankService.DepositIntoAccount((int)userKey, transactionDeposit);
                        break;

                    case Selections.SeeTransactionHistory:
                        IEnumerable <Transactions> transactionHistory = bankService.GetAllTransactionsForAccount((int)userKey);
                        DisplayMessaging.PrettyDisplayTransactions(transactionHistory);
                        break;

                    case Selections.CreateAccount:
                        Account accountToCreate = DisplayMessaging.CreateNewAccountFromUser(bankService);
                        Account createdAccount  = bankService.CreateAccount(accountToCreate);
                        break;

                    case Selections.LogOut:
                        if (bankService.Logout())
                        {
                            userKey = 0;
                            account = null;
                        }
                        break;

                    default:
                        DisplayMessaging.InvalidInput();
                        break;
                    }
                }
            }
        }