Beispiel #1
0
        private static void BankAccountServiceTest(IBankAccountService bankAccountService)
        {
            var accountList = new List <string>
            {
                bankAccountService.CreateAccount(AccountType.Base, NumberGenerator, "Max", "Smith", "*****@*****.**"),
                bankAccountService.CreateAccount(AccountType.Gold, NumberGenerator, "John", "Pitt", "*****@*****.**"),
                bankAccountService.CreateAccount(AccountType.Platinum, NumberGenerator, "Brad", "Fox", "*****@*****.**", 500)
            };

            PrintAccounts(bankAccountService, accountList);

            foreach (var accountNumber in accountList)
            {
                bankAccountService.Deposit(accountNumber, 15);
            }

            PrintAccounts(bankAccountService, accountList);

            bankAccountService.CloseAccount(accountList[1]);
            accountList.RemoveAt(1);
            PrintAccounts(bankAccountService, accountList);

            foreach (var accountNumber in accountList)
            {
                bankAccountService.Withdraw(accountNumber, 5);
            }

            PrintAccounts(bankAccountService, accountList);
        }
Beispiel #2
0
        public async Task <ActionResult <BankAccountViewModel> > CreateBankAccount(BankAccountDTO bankAccount)
        {
            var result = await _bankAccountService.CreateAccount(bankAccount);

            if (!result.Success)
            {
                return(new JsonResult(result)
                {
                    StatusCode = (int)result.StatusCode
                });
            }

            return(CreatedAtAction("GetBankAccount", new { id = result.Value.ClientID }, result.Value));
        }
Beispiel #3
0
        public async Task <ActionResult> OpenAccount(ViewAccountModel account)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            string openedAccountNumber = _bankAccountService.CreateAccount(account.Type, _numberGenerator, account.OwnerFirstName,
                                                                           account.OwnerSecondName, account.OwnerEmail, account.Balance, account.Bonus);

            string subject = "Account is successfully opened!";
            string message = $"Your account number: {openedAccountNumber}";

            await SendMailAsync(account.OwnerEmail, subject, message);

            TempData["accountOpened"] = true;
            return(RedirectToAction("AccountIsOpened"));
        }
Beispiel #4
0
 public void CreateAccount(decimal balance, int limit, string name)
 {
     _bankAccountService.CreateAccount(balance, limit, name);
 }
 public ActionResult Create(BankAccountViewModel requestBankAccountInfo)
 {
     _bankAccountService.CreateAccount(requestBankAccountInfo);
     return(View("Create"));
 }
Beispiel #6
0
 public ActionResult <BankAccount> Post([FromBody] BankAccount bankAccount)
 {
     return(_service.CreateAccount(bankAccount.InterestRate, bankAccount.ActualBalance));
 }