internal AccountResponse PayIn(decimal amount) { var response = new AccountResponse(); var paidIn = PaidIn + amount; if (paidIn > PayInLimit) { throw new InvalidOperationException("Account pay in limit reached"); } if (PayInLimit - paidIn < 500m) { response.IsApproachingPayInLimit = true; } Balance = Balance + amount; PaidIn = PaidIn + amount; return(response); }
internal AccountResponse Withdraw(decimal amount) { var response = new AccountResponse(); decimal balanceAfterWithdrawal = Balance - amount; if (balanceAfterWithdrawal < 0m) { throw new InvalidOperationException("Insufficient funds to withdraw funds"); } if (balanceAfterWithdrawal < 500m) { response.AreFundsLow = true; } Balance = Balance - amount; Withdrawn = Withdrawn - amount; return(response); }