protected void ThrowOnWrongEvent(IAttributeSetInstanceExtensionFieldGroupEvent e) { var id = new System.Text.StringBuilder(); id.Append("[").Append("AttributeSetInstanceExtensionFieldGroup|"); var stateEntityId = this.Id; // Aggregate Id var eventEntityId = e.AttributeSetInstanceExtensionFieldGroupEventId.Id; if (stateEntityId != eventEntityId) { throw DomainError.Named("mutateWrongEntity", "Entity Id {0} in state but entity id {1} in event", stateEntityId, eventEntityId); } id.Append(stateEntityId).Append(","); id.Append("]"); var stateVersion = this.Version; var eventVersion = e.AttributeSetInstanceExtensionFieldGroupEventId.Version; if (stateVersion != eventVersion) { throw OptimisticConcurrencyException.Create(stateVersion, eventVersion, id.ToString()); } }
public void AddAttributeSetInstanceExtensionFieldGroupEvent(IAttributeSetInstanceExtensionFieldGroupEvent e) { _innerStateEvents.Add((AttributeSetInstanceExtensionFieldGroupStateCreatedOrMergePatchedOrDeletedDto)e); }
public virtual AttributeSetInstanceExtensionFieldGroupStateCreatedOrMergePatchedOrDeletedDto ToAttributeSetInstanceExtensionFieldGroupStateEventDto(IAttributeSetInstanceExtensionFieldGroupEvent stateEvent) { if (stateEvent.EventType == StateEventType.Created) { var e = (IAttributeSetInstanceExtensionFieldGroupStateCreated)stateEvent; return(ToAttributeSetInstanceExtensionFieldGroupStateCreatedDto(e)); } else if (stateEvent.EventType == StateEventType.MergePatched) { var e = (IAttributeSetInstanceExtensionFieldGroupStateMergePatched)stateEvent; return(ToAttributeSetInstanceExtensionFieldGroupStateMergePatchedDto(e)); } else if (stateEvent.EventType == StateEventType.Deleted) { var e = (IAttributeSetInstanceExtensionFieldGroupStateDeleted)stateEvent; return(ToAttributeSetInstanceExtensionFieldGroupStateDeletedDto(e)); } throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType)); }