Exemplo n.º 1
0
        protected bool IsRepeatedCommand(IOrderRoleMvoCommand command, IEventStoreAggregateId eventStoreAggregateId, IOrderRoleMvoState state)
        {
            bool repeated = false;

            if (((IOrderRoleMvoStateProperties)state).OrderVersion > command.AggregateVersion)
            {
                var lastEvent = EventStore.GetEvent(typeof(IOrderRoleMvoEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
Exemplo n.º 2
0
        protected virtual void Update(IOrderRoleMvoCommand c, Action <IOrderRoleMvoAggregate> action)
        {
            var aggregateId = c.AggregateId;
            var state       = StateRepository.Get(aggregateId, false);
            var aggregate   = GetOrderRoleMvoAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

            var repeated = IsRepeatedCommand(c, eventStoreAggregateId, state);

            if (repeated)
            {
                return;
            }

            aggregate.ThrowOnInvalidStateTransition(c);
            action(aggregate);
            Persist(eventStoreAggregateId, aggregate, state);
        }
Exemplo n.º 3
0
 private static bool IsCommandCreate(IOrderRoleMvoCommand c)
 {
     return(c.OrderVersion == OrderRoleMvoState.VersionZero);
 }