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

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

            var stateEntityId = this.InventoryPostingRuleId; // Aggregate Id
            var eventEntityId = e.InventoryPostingRuleEventId.InventoryPostingRuleId;

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

            if (stateVersion != eventVersion)
            {
                throw OptimisticConcurrencyException.Create(stateVersion, eventVersion, id.ToString());
            }
        }
 public virtual InventoryPostingRuleStateCreatedOrMergePatchedOrDeletedDto ToInventoryPostingRuleStateEventDto(IInventoryPostingRuleEvent stateEvent)
 {
     if (stateEvent.EventType == StateEventType.Created)
     {
         var e = (IInventoryPostingRuleStateCreated)stateEvent;
         return(ToInventoryPostingRuleStateCreatedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.MergePatched)
     {
         var e = (IInventoryPostingRuleStateMergePatched)stateEvent;
         return(ToInventoryPostingRuleStateMergePatchedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.Deleted)
     {
         var e = (IInventoryPostingRuleStateDeleted)stateEvent;
         return(ToInventoryPostingRuleStateDeletedDto(e));
     }
     throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType));
 }
Beispiel #3
0
 public void AddInventoryPostingRuleEvent(IInventoryPostingRuleEvent e)
 {
     _innerStateEvents.Add((InventoryPostingRuleStateCreatedOrMergePatchedOrDeletedDto)e);
 }