Пример #1
0
        protected void ThrowOnWrongEvent(IUomEvent e)
        {
            var id = new System.Text.StringBuilder();

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

            var stateEntityId = this.UomId; // Aggregate Id
            var eventEntityId = e.UomEventId.UomId;

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

            if (stateVersion != eventVersion)
            {
                throw OptimisticConcurrencyException.Create(stateVersion, eventVersion, id.ToString());
            }
        }
Пример #2
0
 public virtual UomStateCreatedOrMergePatchedOrDeletedDto ToUomStateEventDto(IUomEvent stateEvent)
 {
     if (stateEvent.EventType == StateEventType.Created)
     {
         var e = (IUomStateCreated)stateEvent;
         return(ToUomStateCreatedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.MergePatched)
     {
         var e = (IUomStateMergePatched)stateEvent;
         return(ToUomStateMergePatchedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.Deleted)
     {
         var e = (IUomStateDeleted)stateEvent;
         return(ToUomStateDeletedDto(e));
     }
     throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType));
 }
Пример #3
0
 public void AddUomEvent(IUomEvent e)
 {
     _innerStateEvents.Add((UomStateCreatedOrMergePatchedOrDeletedDto)e);
 }