protected void ThrowOnWrongEvent(IUserLoginMvoStateEvent stateEvent) { var id = new System.Text.StringBuilder(); id.Append("[").Append("UserLoginMvo|"); var stateEntityId = this.UserLoginId; // Aggregate Id var eventEntityId = stateEvent.StateEventId.UserLoginId; // EntityBase.Aggregate.GetStateEventIdPropertyIdName(); 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.UserVersion; var eventVersion = stateEvent.StateEventId.UserVersion; if (stateVersion != eventVersion) { throw OptimisticConcurrencyException.Create(stateVersion, eventVersion, id.ToString()); } }
protected void ThrowOnWrongEvent(IUserLoginMvoStateEvent stateEvent) { var stateEntityId = this.UserLoginId; // Aggregate Id var eventEntityId = stateEvent.StateEventId.UserLoginId; // EntityBase.Aggregate.GetStateEventIdPropertyIdName(); if (stateEntityId != eventEntityId) { throw DomainError.Named("mutateWrongEntity", "Entity Id {0} in state but entity id {1} in event", stateEntityId, eventEntityId); } var stateVersion = this.UserVersion; var eventVersion = stateEvent.StateEventId.UserVersion; if (stateVersion != eventVersion) { throw DomainError.Named("concurrencyConflict", "Conflict between state version {0} and event version {1}", stateVersion, eventVersion); } }
public virtual UserLoginMvoStateCreatedOrMergePatchedOrDeletedDto ToUserLoginMvoStateEventDto(IUserLoginMvoStateEvent stateEvent) { if (stateEvent.StateEventType == StateEventType.Created) { var e = (IUserLoginMvoStateCreated)stateEvent; return(ToUserLoginMvoStateCreatedDto(e)); } else if (stateEvent.StateEventType == StateEventType.MergePatched) { var e = (IUserLoginMvoStateMergePatched)stateEvent; return(ToUserLoginMvoStateMergePatchedDto(e)); } else if (stateEvent.StateEventType == StateEventType.Deleted) { var e = (IUserLoginMvoStateDeleted)stateEvent; return(ToUserLoginMvoStateDeletedDto(e)); } throw DomainError.Named("invalidStateEventType", String.Format("Invalid state event type: {0}", stateEvent.StateEventType)); }
public void AddUserLoginMvoEvent(IUserLoginMvoStateEvent e) { _innerStateEvents.Add((UserLoginMvoStateCreatedOrMergePatchedOrDeletedDto)e); }