Exemple #1
0
        protected void ThrowOnWrongEvent(IShipmentItemMvoEvent e)
        {
            var id = new System.Text.StringBuilder();

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

            var stateEntityId = this.ShipmentItemId; // Aggregate Id
            var eventEntityId = e.ShipmentItemMvoEventId.ShipmentItemId;

            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.ShipmentVersion;
            var eventVersion = e.ShipmentItemMvoEventId.ShipmentVersion;

            if (stateVersion != eventVersion)
            {
                throw OptimisticConcurrencyException.Create(stateVersion, eventVersion, id.ToString());
            }
        }
 public virtual ShipmentItemMvoStateCreatedOrMergePatchedOrDeletedDto ToShipmentItemMvoStateEventDto(IShipmentItemMvoEvent stateEvent)
 {
     if (stateEvent.EventType == StateEventType.Created)
     {
         var e = (IShipmentItemMvoStateCreated)stateEvent;
         return(ToShipmentItemMvoStateCreatedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.MergePatched)
     {
         var e = (IShipmentItemMvoStateMergePatched)stateEvent;
         return(ToShipmentItemMvoStateMergePatchedDto(e));
     }
     throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType));
 }
Exemple #3
0
 public void AddShipmentItemMvoEvent(IShipmentItemMvoEvent e)
 {
     _innerStateEvents.Add((ShipmentItemMvoStateCreatedOrMergePatchedOrDeletedDto)e);
 }