public async Task ExecuteAsync(HookType type, IDomainEntityContext <Invoice> context, CancellationToken cancellationToken) { switch (context.EditMode) { case EditMode.Create: await context.AddEventAsync(InvoiceCreatedEvent.Create(_correlationIdProvider.Id, context.Entity.Id, _currentUser.Id), cancellationToken); break; case EditMode.Update: await context.AddEventAsync(InvoiceUpdatedEvent.Create(_correlationIdProvider.Id, context.Entity.Id, _currentUser.Id), cancellationToken); break; case EditMode.Delete: await context.AddEventAsync(InvoiceDeletedEvent.Create(_correlationIdProvider.Id, context.Entity.Id, _currentUser.Id), cancellationToken); break; } }
public async Task Handle(InvoiceDeletedEvent notification, CancellationToken cancellationToken) { _logger.LogInformation("InvoiceDeletedEvent: {invoice}", notification); return; }