Esempio n. 1
0
        protected void ThrowOnWrongEvent(IGoodIdentificationTypeEvent e)
        {
            var id = new System.Text.StringBuilder();

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

            var stateEntityId = this.GoodIdentificationTypeId; // Aggregate Id
            var eventEntityId = e.GoodIdentificationTypeEventId.GoodIdentificationTypeId;

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

            if (stateVersion != eventVersion)
            {
                throw OptimisticConcurrencyException.Create(stateVersion, eventVersion, id.ToString());
            }
        }
 public virtual GoodIdentificationTypeStateCreatedOrMergePatchedOrDeletedDto ToGoodIdentificationTypeStateEventDto(IGoodIdentificationTypeEvent stateEvent)
 {
     if (stateEvent.EventType == StateEventType.Created)
     {
         var e = (IGoodIdentificationTypeStateCreated)stateEvent;
         return(ToGoodIdentificationTypeStateCreatedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.MergePatched)
     {
         var e = (IGoodIdentificationTypeStateMergePatched)stateEvent;
         return(ToGoodIdentificationTypeStateMergePatchedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.Deleted)
     {
         var e = (IGoodIdentificationTypeStateDeleted)stateEvent;
         return(ToGoodIdentificationTypeStateDeletedDto(e));
     }
     throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType));
 }
Esempio n. 3
0
 public void AddGoodIdentificationTypeEvent(IGoodIdentificationTypeEvent e)
 {
     _innerStateEvents.Add((GoodIdentificationTypeStateCreatedOrMergePatchedOrDeletedDto)e);
 }