protected bool IsRepeatedCommand(IInventoryItemRequirementEntryMvoCommand command, IEventStoreAggregateId eventStoreAggregateId, IInventoryItemRequirementEntryMvoState state)
        {
            bool repeated = false;

            if (((IInventoryItemRequirementEntryMvoStateProperties)state).InventoryItemRequirementVersion > command.AggregateVersion)
            {
                var lastEvent = EventStore.GetEvent(typeof(IInventoryItemRequirementEntryMvoEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
        protected virtual void Update(IInventoryItemRequirementEntryMvoCommand c, Action <IInventoryItemRequirementEntryMvoAggregate> action)
        {
            var aggregateId = c.AggregateId;
            var state       = StateRepository.Get(aggregateId, false);
            var aggregate   = GetInventoryItemRequirementEntryMvoAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

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

            if (repeated)
            {
                return;
            }

            aggregate.ThrowOnInvalidStateTransition(c);
            action(aggregate);
            Persist(eventStoreAggregateId, aggregate, state);
        }
Ejemplo n.º 3
0
 private static bool IsCommandCreate(IInventoryItemRequirementEntryMvoCommand c)
 {
     return(c.InventoryItemRequirementVersion == InventoryItemRequirementEntryMvoState.VersionZero);
 }