示例#1
0
        protected void ThrowOnWrongEvent(IUserLoginMvoEvent e)
        {
            var id = new System.Text.StringBuilder();

            id.Append("[").Append("UserLoginMvo|");

            var stateEntityId = this.UserLoginId; // Aggregate Id
            var eventEntityId = e.UserLoginMvoEventId.UserLoginId;

            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 = e.UserLoginMvoEventId.UserVersion;

            if (stateVersion != eventVersion)
            {
                throw OptimisticConcurrencyException.Create(stateVersion, eventVersion, id.ToString());
            }
        }
 public virtual UserLoginMvoStateCreatedOrMergePatchedOrDeletedDto ToUserLoginMvoStateEventDto(IUserLoginMvoEvent stateEvent)
 {
     if (stateEvent.EventType == StateEventType.Created)
     {
         var e = (IUserLoginMvoStateCreated)stateEvent;
         return(ToUserLoginMvoStateCreatedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.MergePatched)
     {
         var e = (IUserLoginMvoStateMergePatched)stateEvent;
         return(ToUserLoginMvoStateMergePatchedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.Deleted)
     {
         var e = (IUserLoginMvoStateDeleted)stateEvent;
         return(ToUserLoginMvoStateDeletedDto(e));
     }
     throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType));
 }
示例#3
0
 public void AddUserLoginMvoEvent(IUserLoginMvoEvent e)
 {
     _innerStateEvents.Add((UserLoginMvoStateCreatedOrMergePatchedOrDeletedDto)e);
 }