예제 #1
0
        public Response<Account> MakeDeposit(DepositRequest request)
        {
            var response = new Response<Account>();
            var accountToUpdate = request.Account;

            try
            {
                if (request.DepositAmount <= 0)
                {
                    response.Success = false;
                    response.Message = "Must deposit a positive amount.";
                }
                else
                {
                    accountToUpdate.Balance += request.DepositAmount;

                    var repo = new AccountRepository();
                    repo.UpdateAccount(accountToUpdate);
                    response.Success = true;
                    response.Data = accountToUpdate;
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }

            return response;
        }
예제 #2
0
        public void Execute(Account account)
        {
            decimal amount = GetDepositAmount();
            var ops = new AccountOperations();
            var request = new DepositRequest()
            {
                Account = account,
                DepositAmount = amount
            };

            var response = ops.MakeDeposit(request);

            if (response.Success)
            {
                Console.Clear();
                Console.WriteLine("Deposited to account {0}, New Balance: {1:C}", response.Data.AccountNumber, response.Data.Balance);
                UserInteractions.PressKeyToContinue();
            }
            else
            {
                Console.Clear();
                Console.WriteLine("An Error Occured:  {0}", response.Message);
                UserInteractions.PressKeyToContinue();
            }
        }
        public void CanDepositMoney()
        {
            var ops = new AccountOperations();
            var loadAccountResponse = ops.GetAccount("2");
            var request = new DepositRequest();
            request.Account = loadAccountResponse.Data;
            request.DepositAmount = 100.00M;
            var depositResponse = ops.MakeDeposit(request);

            var reloadAccount = ops.GetAccount("2");

            Assert.AreEqual("2", reloadAccount.Data.AccountNumber);
            Assert.AreEqual("Bob", reloadAccount.Data.FirstName);
            Assert.AreEqual(223.00M, reloadAccount.Data.Balance);
        }
예제 #4
0
        public void Execute(Account account)
        {
            // get transfer amount
            decimal transferAmount = GetTransferAmount(account);
            var ops = new AccountOperations();

            //withdraw transfer amount from that account
            var fromAccountRequest = new WithDrawalRequest()
            {
                Account = account,
                WithdrawalAmount = transferAmount
            };
            var fromAccountResponse = ops.MakeWithDrawal(fromAccountRequest);

            string getTransferAccount = GetTransferAccount();

            //trying to assign the transferTo account as the account in the deposit request.
            //have to change string toAccount to Account
            var getAccountResponse = ops.GetAccount(getTransferAccount);
            var toAccount = getAccountResponse.Data;

            var toAccountRequest = new DepositRequest()
            {
                Account = toAccount,
                DepositAmount = transferAmount
            };

            var toAccountResponse = ops.MakeDeposit(toAccountRequest);

            if (getAccountResponse.Success)
            {
                Console.Clear();
                Console.WriteLine("Transfered from account {0}, New Balance: {1:C}", fromAccountResponse.Data.AccountNumber, toAccountResponse.Data.Balance);
                UserInteractions.PressKeyToContinue();
            }
            else
            {
                Console.Clear();
                Console.WriteLine("An Error Occured:  {0}", fromAccountResponse.Message);
                UserInteractions.PressKeyToContinue();
            }
        }