コード例 #1
0
 public void Handle(OrderCreated @event)
 {
     _auditRepository.Add(new Audit()
     {
         Id          = @event.EventId.ToString(),
         Name        = @event.GetType().ToString(),
         Details     = @event.ProductName + " - " + @event.Price,
         CreatedTime = @event.EventPublished.UtcDateTime
     });
 }
コード例 #2
0
        public async Task Handle(OrderCreated notification, CancellationToken cancellationToken)
        {
            IEnumerable <ISagaContextMetadata> metadata = new List <ISagaContextMetadata>();
            await _coordinator.ProcessAsync(notification,
                                            SagaContext.Create((SagaId)notification.OrderId.ToString(), notification.GetType().Name, metadata));

            // once every thing is processed in the handler, commit changes to DB.
            // This can be moved else where depending on the user needs.
            await SagaUnitOfWork.CommitAsync();
        }
コード例 #3
0
 public async Task Handle(OrderCreated notification, CancellationToken cancellationToken)
 {
     // DO WORK HERE
     IEnumerable <ISagaContextMetadata> metadata = new List <ISagaContextMetadata>();
     await _coordinator.ProcessAsync(notification,
                                     SagaContext.Create((SagaId)notification.OrderId.ToString(), notification.GetType().Name, metadata));
 }