Example #1
0
        protected bool IsRepeatedCommand(ISellableInventoryItemEntryMvoCommand command, IEventStoreAggregateId eventStoreAggregateId, ISellableInventoryItemEntryMvoState state)
        {
            bool repeated = false;

            if (((ISellableInventoryItemEntryMvoStateProperties)state).SellableInventoryItemVersion > command.AggregateVersion)
            {
                var lastEvent = EventStore.GetEvent(typeof(ISellableInventoryItemEntryMvoEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
Example #2
0
        protected virtual void Update(ISellableInventoryItemEntryMvoCommand c, Action <ISellableInventoryItemEntryMvoAggregate> action)
        {
            var aggregateId = c.AggregateId;
            var state       = StateRepository.Get(aggregateId, false);
            var aggregate   = GetSellableInventoryItemEntryMvoAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

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

            if (repeated)
            {
                return;
            }

            aggregate.ThrowOnInvalidStateTransition(c);
            action(aggregate);
            Persist(eventStoreAggregateId, aggregate, state);
        }
Example #3
0
 private static bool IsCommandCreate(ISellableInventoryItemEntryMvoCommand c)
 {
     return(c.SellableInventoryItemVersion == SellableInventoryItemEntryMvoState.VersionZero);
 }