Пример #1
0
        protected void ThrowOnWrongEvent(IMovementTypeEvent e)
        {
            var id = new System.Text.StringBuilder();

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

            var stateEntityId = this.MovementTypeId; // Aggregate Id
            var eventEntityId = e.MovementTypeEventId.MovementTypeId;

            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.MovementTypeEventId.Version;

            if (stateVersion != eventVersion)
            {
                throw OptimisticConcurrencyException.Create(stateVersion, eventVersion, id.ToString());
            }
        }
 public virtual MovementTypeStateCreatedOrMergePatchedOrDeletedDto ToMovementTypeStateEventDto(IMovementTypeEvent stateEvent)
 {
     if (stateEvent.EventType == StateEventType.Created)
     {
         var e = (IMovementTypeStateCreated)stateEvent;
         return(ToMovementTypeStateCreatedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.MergePatched)
     {
         var e = (IMovementTypeStateMergePatched)stateEvent;
         return(ToMovementTypeStateMergePatchedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.Deleted)
     {
         var e = (IMovementTypeStateDeleted)stateEvent;
         return(ToMovementTypeStateDeletedDto(e));
     }
     throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType));
 }
Пример #3
0
 public void AddMovementTypeEvent(IMovementTypeEvent e)
 {
     _innerStateEvents.Add((MovementTypeStateCreatedOrMergePatchedOrDeletedDto)e);
 }