Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }