コード例 #1
0
 //Handles the loan LoanElectedWithHoldsEvent by firing a work item to WFM
 private void HandleLoanElectedWithHoldsEvent(PaymentEvent paymentEvent)
 {
     Trace.WriteLine("Handlinge LoanElectedWithHoldsEvent...");
     workforceClient.PublishWorkItem(paymentEvent);
     paymentEvent.MarkAsHandled();
     dbContext.SaveChanges();
 }
コード例 #2
0
        //Publishes an event out over the bus.
        public void Publish(PaymentEvent paymentEvent)
        {
            //We could test to see what happens in the event of an error.
            //For example, we may not be able to communicate with our bus.
            //Uncomment the following line to test this.
            //throw new Exception("CommunicationException");

            //This is being faked for now, so just write to the trace log.
            Trace.WriteLine("ServiceBus: " + paymentEvent.ToString());
        }
コード例 #3
0
        //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();
        }
コード例 #4
0
        public void HandlePaymentEvent(PaymentEvent paymentEvent)
        {
            if (paymentEvent == null)
            {
                throw new ArgumentNullException("paymentEvent");
            }

            switch (paymentEvent.EventType)
            {
                case PaymentEventType.PaymentCreated:
                    HandlePaymentCreatedEvent(paymentEvent);
                    break;
                case PaymentEventType.LoanElectedWithHolds:
                    HandleLoanElectedWithHoldsEvent(paymentEvent);
                    break;
                case PaymentEventType.PaymentEligible:
                    HandlePaymentEligibleEvent(paymentEvent);
                    break;
                default:
                    throw new InvalidOperationException();
            }
        }
コード例 #5
0
 //Handles the EligiblePaymentEvent by forwarding it out over the service bus.
 private void HandlePaymentEligibleEvent(PaymentEvent paymentEvent)
 {
     Trace.WriteLine("Handlinge PaymentEligibleEvent...");
     serviceBusClient.Publish(paymentEvent);
     paymentEvent.MarkAsHandled();
     dbContext.SaveChanges();
 }
コード例 #6
0
ファイル: Payment.cs プロジェクト: kumardh/PaymentsEventing
        private void RaiseEvent(PaymentEvent paymentEvent)
        {
            if (Events == null)
            {
                Events = new List<PaymentEvent>();
            }

            Events.Add(paymentEvent);
        }