//Handles the PaymentCreatedEvent by starting eligibility.
        private void HandlePaymentCreatedEvent(PaymentEvent paymentEvent)
        {
            Trace.WriteLine("Handling PaymentCreatedEvent...");
            var payment = dbContext
                .Payments
                .Where(x=>x.PaymentId == paymentEvent.PaymentId)
                .First();

            var loan = new Loan(true);
            payment.ElectLoan(loan);
            paymentEvent.MarkAsHandled();
            dbContext.SaveChanges();
        }
Пример #2
0
        /// <summary>
        /// Elects a loan with an escrow account that will provide payment services.
        /// </summary>
        public void ElectLoan(Loan loan)
        {
            if (loan == null)
            {
                throw new ArgumentNullException("loan");
            }

            if (ElectedLoan != null)
            {
                throw new InvalidOperationException("A loan as already been elected.");
            }

            ElectedLoan = loan;

            if (ElectedLoan.HasHolds)
            {
                RaiseEvent(new PaymentEvent(PaymentKey, PaymentEventType.LoanElectedWithHolds));
            }
        }