public async Task HandleAsync(T @event, ICorrelationContext context) { if (@event.BelongsToSaga()) { var sagaContext = SagaContext.FromCorrelationContext(context); await _sagaCoordinator.ProcessAsync(@event, sagaContext); } switch (@event) { case IRejectedEvent rejectedEvent: await _operationsStorage.SetAsync(context.Id, context.UserId, context.Name, OperationState.Rejected, context.Resource, rejectedEvent.Code, rejectedEvent.Reason); await _operationPublisher.RejectAsync(context, rejectedEvent.Code, rejectedEvent.Reason); return; case IEvent _: await _operationsStorage.SetAsync(context.Id, context.UserId, context.Name, OperationState.Completed, context.Resource); await _operationPublisher.CompleteAsync(context); return; } }
public async Task HandleAsync(T @event, ICorrelationContext context) { switch (@event) { case IRejectedEvent rejectedEvent: await _operationsStorage.SetAsync(context.Id, context.UserId, context.Name, OperationState.Rejected, context.Resource, context.ResourceId, rejectedEvent.Code, rejectedEvent.Reason); await _operationPublisher.RejectAsync(context, rejectedEvent.Code, rejectedEvent.Reason); return; case IDomainEvent _: await _operationsStorage.SetAsync(context.Id, context.UserId, context.Name, OperationState.Completed, context.Resource, context.ResourceId); await _operationPublisher.CompleteAsync(context); return; } }