protected bool IsRepeatedCommand(IUomTypeCommand command, IEventStoreAggregateId eventStoreAggregateId, IUomTypeState state) { bool repeated = false; if (((IUomTypeStateProperties)state).Version == command.AggregateVersion + 1) { if (state.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
protected virtual void Update(IUomTypeCommand c, Action <IUomTypeAggregate> action) { var aggregateId = c.AggregateId; var state = StateRepository.Get(aggregateId, false); var aggregate = GetUomTypeAggregate(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(IUomTypeCommand c) { return(c.Version == UomTypeState.VersionZero); }