private Transfer MakeTransferWithAmountWithinLimit(string counterAccount, Money amount) { int sum = Accounts.CalculateSum(counterAccount); if (sum % 11 == 0) { // 3. Look up counter account and make transfer object: CheckingAccount acct = Accounts.FindAcctByNumber(counterAccount); Transfer result = new Transfer(this, acct, amount); return(result); } else { throw new BusinessException("Invalid account number!"); } }
private Transfer MakeTransferWithValidAccountNumber(string counterAccount, Money amount) { int sum = Accounts.CalculateSum(counterAccount); if (sum % 11 == 0) { // 2. Look up counter account and make transfer object: CheckingAccount acct = Accounts.FindAcctByNumber(counterAccount); Transfer result = new Transfer(this, acct, amount); // <2> // 3. Check whether withdrawal is to registered counter account: if (result.CounterAccount.Equals(this.RegisteredCounterAccount)) { return(result); } else { throw new BusinessException("Counter-account not registered!"); } } else { throw new BusinessException("Invalid account number!!"); } }