protected override Task OnBeforeEventHandling(EventHandleFlowContext context)
        {
            if (context.Event.Version != context.NowState.NextVersion)
            {
                throw new VersionErrorException(context.NowState.Version, context.Event.Version);
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 2
0
 protected override Task OnAfterEventHandled(EventHandleFlowContext context,
                                             IState newState)
 {
     _eventHandledNotificationFlow.OnNewEventHandled(new EventNotifierContext
     {
         Event        = context.Event,
         CurrentState = newState,
         OldState     = context.NowState
     });
     return(Task.CompletedTask);
 }
Ejemplo n.º 3
0
        protected override Task OnBeforeEventHandling(EventHandleFlowContext context)
        {
            context.Event.Version = context.NowState.NextVersion;
            return(SaveEvent(context.Event));

            async Task SaveEvent(IEvent evt)
            {
                try
                {
                    _logger.LogTrace("start to save event {@event}", evt);
                    await _eventSaver.SaveEventAsync(evt);
                }
                catch (EventSavingException e)
                {
                    _logger.LogError(e,
                                     "failed to save event, please check event store {@event}", evt);
                    throw;
                }
            }
        }
 protected override Task OnAfterEventHandled(EventHandleFlowContext context, IState newState)
 {
     return(Task.CompletedTask);
 }