protected bool IsRepeatedCommand(IOrderItemShipGrpInvReservationCommand command, IEventStoreAggregateId eventStoreAggregateId, IOrderItemShipGrpInvReservationState state)
        {
            bool repeated = false;

            if (((IOrderItemShipGrpInvReservationStateProperties)state).Version > command.AggregateVersion)
            {
                var lastEvent = EventStore.GetEvent(typeof(IOrderItemShipGrpInvReservationEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
        protected virtual void Update(IOrderItemShipGrpInvReservationCommand c, Action <IOrderItemShipGrpInvReservationAggregate> action)
        {
            var aggregateId = c.AggregateId;
            var state       = StateRepository.Get(aggregateId, false);
            var aggregate   = GetOrderItemShipGrpInvReservationAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

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

            if (repeated)
            {
                return;
            }

            aggregate.ThrowOnInvalidStateTransition(c);
            action(aggregate);
            Persist(eventStoreAggregateId, aggregate, state);
        }
コード例 #3
0
 private static bool IsCommandCreate(IOrderItemShipGrpInvReservationCommand c)
 {
     return(c.Version == OrderItemShipGrpInvReservationState.VersionZero);
 }