protected void ThrowOnWrongEvent(IOrderItemShipGroupAssociationMvoEvent e)
        {
            var id = new System.Text.StringBuilder();

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

            var stateEntityId = this.OrderItemShipGroupAssociationId; // Aggregate Id
            var eventEntityId = e.OrderItemShipGroupAssociationMvoEventId.OrderItemShipGroupAssociationId;

            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.OrderVersion;
            var eventVersion = e.OrderItemShipGroupAssociationMvoEventId.OrderVersion;

            if (stateVersion != eventVersion)
            {
                throw OptimisticConcurrencyException.Create(stateVersion, eventVersion, id.ToString());
            }
        }
Пример #2
0
 public void AddOrderItemShipGroupAssociationMvoEvent(IOrderItemShipGroupAssociationMvoEvent e)
 {
     _innerStateEvents.Add((OrderItemShipGroupAssociationMvoStateCreatedOrMergePatchedOrDeletedDto)e);
 }
 public virtual OrderItemShipGroupAssociationMvoStateCreatedOrMergePatchedOrDeletedDto ToOrderItemShipGroupAssociationMvoStateEventDto(IOrderItemShipGroupAssociationMvoEvent stateEvent)
 {
     if (stateEvent.EventType == StateEventType.Created)
     {
         var e = (IOrderItemShipGroupAssociationMvoStateCreated)stateEvent;
         return(ToOrderItemShipGroupAssociationMvoStateCreatedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.MergePatched)
     {
         var e = (IOrderItemShipGroupAssociationMvoStateMergePatched)stateEvent;
         return(ToOrderItemShipGroupAssociationMvoStateMergePatchedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.Deleted)
     {
         var e = (IOrderItemShipGroupAssociationMvoStateDeleted)stateEvent;
         return(ToOrderItemShipGroupAssociationMvoStateDeletedDto(e));
     }
     throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType));
 }