Exemplo n.º 1
0
        protected void ThrowOnWrongEvent(IPhysicalInventoryEvent e)
        {
            var id = new System.Text.StringBuilder();

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

            var stateEntityId = this.DocumentNumber; // Aggregate Id
            var eventEntityId = e.PhysicalInventoryEventId.DocumentNumber;

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

            if (stateVersion != eventVersion)
            {
                throw OptimisticConcurrencyException.Create(stateVersion, eventVersion, id.ToString());
            }
        }
Exemplo n.º 2
0
 public static void ThrowOnInconsistentEventIds(IPhysicalInventoryEvent oe, IPhysicalInventoryLineEvent e)
 {
     if (!oe.PhysicalInventoryEventId.DocumentNumber.Equals(e.PhysicalInventoryLineEventId.PhysicalInventoryDocumentNumber))
     {
         throw DomainError.Named("inconsistentEventIds", "Outer Id DocumentNumber {0} but inner id PhysicalInventoryDocumentNumber {1}",
                                 oe.PhysicalInventoryEventId.DocumentNumber, e.PhysicalInventoryLineEventId.PhysicalInventoryDocumentNumber);
     }
 }
Exemplo n.º 3
0
 public void AddPhysicalInventoryEvent(IPhysicalInventoryEvent e)
 {
     _innerStateEvents.Add((PhysicalInventoryStateCreatedOrMergePatchedOrDeletedDto)e);
 }
 public virtual PhysicalInventoryStateCreatedOrMergePatchedOrDeletedDto ToPhysicalInventoryStateEventDto(IPhysicalInventoryEvent stateEvent)
 {
     if (stateEvent.EventType == StateEventType.Created)
     {
         var e = (IPhysicalInventoryStateCreated)stateEvent;
         return(ToPhysicalInventoryStateCreatedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.MergePatched)
     {
         var e = (IPhysicalInventoryStateMergePatched)stateEvent;
         return(ToPhysicalInventoryStateMergePatchedDto(e));
     }
     throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType));
 }