public AccountDepositResponse Deposit(string accountNumber, decimal amount) { AccountDepositResponse response = new AccountDepositResponse(); response.Account = _accountRepository.LoadAccount(accountNumber); if (response.Account == null) { response.Success = false; response.Message = $"{accountNumber} is not a valid account."; return(response); } else { response.Success = true; } IDeposit depositRule = DepositRulesFactory.Create(response.Account.Type); response = depositRule.Deposit(response.Account, amount); if (response.Success) { _accountRepository.SaveAccount(response.Account); } return(response); }
public AccountDepositResponse Deposit(string accountNumber, decimal amount) { AccountDepositResponse accountDepositResponse = new AccountDepositResponse { Account = _accountRepository.LoadAccount(accountNumber) }; if (accountDepositResponse.Account == null) { Console.WriteLine(accountNumber + " is not an account number."); return(accountDepositResponse); } else { accountDepositResponse.Amount = amount; accountDepositResponse.Success = true; } IDeposit depositRule = DepositRulesFactory.Create(accountDepositResponse.Account.Type); accountDepositResponse = depositRule.Deposit(accountDepositResponse.Account, amount); if (accountDepositResponse.Success) { _accountRepository.SaveAccount(accountDepositResponse.Account); } return(accountDepositResponse); }
public AccountDepositResponse Deposit(string accountNumber, decimal amount) { AccountDepositResponse response = new AccountDepositResponse(); try { response.Account = _accountRepository.LoadAccount(accountNumber); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; return(response); } if (response.Account == null) { response.Success = false; response.Message = $"{accountNumber} is not a valid account."; return(response); } else if (response.Account.Name == "Error") { response.Success = false; response.Message = "Error: something went wrong while accessing the file repository. Contact IT."; return(response); } else { response.Success = true; } IDeposit depositRule = DepositRulesFactory.CreateDepositRule(response.Account.Type); response = depositRule.Deposit(response.Account, amount); if (response.Success) { try { _accountRepository.SaveAccount(response.Account); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; return(response); } } return(response); }
public void PremiumAccountDepositTests(string accountNumber, string name, decimal balance, AccountType accountType, decimal amount, bool expectedResult) { IDeposit deposit = DepositRulesFactory.Create(AccountType.Premium); Account account = new Account(); account.AccountNumber = accountNumber; account.Name = name; account.Balance = balance; account.Type = accountType; AccountDepositResponse response = deposit.Deposit(account, amount); Assert.AreEqual(expectedResult, response.Success); }
[TestCase("33333", "BasicAccount", 100, AccountType.Basic, 250, true)] //Pass public void BasicAccount_DepositRuleTest(string accountNumber, string name, decimal balance, AccountType accountType, decimal amount, bool expectedResult) { IDeposit depositRule = DepositRulesFactory.Create(AccountType.Basic); Account account = new Account() { AccountNumber = accountNumber, Balance = balance, Name = name, Type = accountType }; AccountDepositResponse response = depositRule.Deposit(account, amount); Assert.AreEqual(expectedResult, response.Success); }
public void FreeAccountDepositRuleTest(string accountNumber, string name, decimal balance, AccountType accountType, decimal amount, bool expectedResult) { FreeAccountDepositRule DepositRule = new FreeAccountDepositRule(); Account account = new Account(); IDeposit deposit = DepositRule; AccountType type = account.Type; account.AccountNumber = accountNumber; account.Type = accountType; account.Name = name; account.Balance = balance; AccountDepositResponse response = deposit.Deposit(account, amount); Assert.AreEqual(expectedResult, response.Success); }
public void Call() { switch (_action) { case DomainModels.Action.Deposit: _depositService.Deposit(_bankAcount, _bankCommandArgs.DepositAmount); Success = true; break; case DomainModels.Action.WithDraw: _withdrawlService.WithDrawl(_bankAcount, _bankCommandArgs.WithdrawlAmount); Success = true; break; default: Success = false; break; } }
virtual public void TransferTo(Money amount, IDeposit toWallet) { toWallet.Deposit(this.Withdraw(amount), this); }