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 }); }
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(); }
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)); }