public AccountWithdrawlResponse Withdrawl(string accountNumber, decimal amount) { AccountWithdrawlResponse response = new AccountWithdrawlResponse(); 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; } IWithdrawl withdrawlRule = WithdrawlRulesFactory.Create(response.Account.Type); response = withdrawlRule.Withdrawl(response.Account, amount); if (response.Success) { _accountRepository.SaveAccount(response.Account); } return(response); }
public BankAccountCommand(BankAccount account, DomainModels.Action action, BankCommandArguments bankCmdArgs, IDeposit depositService, IWithdrawl withdrawlService) { _bankAcount = account ?? throw new ArgumentNullException(nameof(account), $"cannot have null value for ${nameof(account)}"); _action = action; _bankCommandArgs = bankCmdArgs ?? throw new ArgumentNullException(nameof(bankCmdArgs), $"cannot have null value for ${nameof(bankCmdArgs)}"); _depositService = depositService ?? throw new ArgumentNullException(nameof(depositService), $"cannot have null value for ${nameof(depositService)}"); _withdrawlService = withdrawlService ?? throw new ArgumentNullException(nameof(withdrawlService), $"cannot have null value for ${nameof(withdrawlService)}"); }