protected bool IsRepeatedCommand(IShipmentPackageContentMvoCommand command, IEventStoreAggregateId eventStoreAggregateId, IShipmentPackageContentMvoState state)
        {
            bool repeated = false;

            if (((IShipmentPackageContentMvoStateProperties)state).ShipmentPackageVersion > command.AggregateVersion)
            {
                var lastEvent = EventStore.GetEvent(typeof(IShipmentPackageContentMvoEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
        protected virtual void Update(IShipmentPackageContentMvoCommand c, Action <IShipmentPackageContentMvoAggregate> action)
        {
            var aggregateId = c.AggregateId;
            var state       = StateRepository.Get(aggregateId, false);
            var aggregate   = GetShipmentPackageContentMvoAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

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

            if (repeated)
            {
                return;
            }

            aggregate.ThrowOnInvalidStateTransition(c);
            action(aggregate);
            Persist(eventStoreAggregateId, aggregate, state);
        }
 private static bool IsCommandCreate(IShipmentPackageContentMvoCommand c)
 {
     return(c.ShipmentPackageVersion == ShipmentPackageContentMvoState.VersionZero);
 }