protected bool IsRepeatedCommand(IOrderShipGroupMvoCommand command, IEventStoreAggregateId eventStoreAggregateId, IOrderShipGroupMvoState state) { bool repeated = false; if (((IOrderShipGroupMvoStateProperties)state).OrderVersion > command.AggregateVersion) { var lastEvent = EventStore.GetEvent(typeof(IOrderShipGroupMvoEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
protected virtual void Update(IOrderShipGroupMvoCommand c, Action <IOrderShipGroupMvoAggregate> action) { var aggregateId = c.AggregateId; var state = StateRepository.Get(aggregateId, false); var aggregate = GetOrderShipGroupMvoAggregate(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(IOrderShipGroupMvoCommand c) { return(c.OrderVersion == OrderShipGroupMvoState.VersionZero); }