protected bool IsRepeatedCommand(IAttributeSetInstanceExtensionFieldMvoCommand command, IEventStoreAggregateId eventStoreAggregateId, IAttributeSetInstanceExtensionFieldMvoState state)
        {
            bool repeated = false;

            if (((IAttributeSetInstanceExtensionFieldMvoStateProperties)state).AttrSetInstEFGroupVersion > command.AggregateVersion)
            {
                var lastEvent = EventStore.FindLastEvent(typeof(IAttributeSetInstanceExtensionFieldMvoStateEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
        protected virtual void Update(IAttributeSetInstanceExtensionFieldMvoCommand c, Action <IAttributeSetInstanceExtensionFieldMvoAggregate> action)
        {
            var aggregateId = c.AggregateId;
            var state       = StateRepository.Get(aggregateId);
            var aggregate   = GetAttributeSetInstanceExtensionFieldMvoAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

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

            if (repeated)
            {
                return;
            }

            aggregate.ThrowOnInvalidStateTransition(c);
            action(aggregate);
            EventStore.AppendEvents(eventStoreAggregateId, ((IAttributeSetInstanceExtensionFieldMvoStateProperties)state).AttrSetInstEFGroupVersion, aggregate.Changes, () => { StateRepository.Save(state); });
        }
 private static bool IsCommandCreate(IAttributeSetInstanceExtensionFieldMvoCommand c)
 {
     return(c.AttrSetInstEFGroupVersion == AttributeSetInstanceExtensionFieldMvoState.VersionZero);
 }