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

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

            var stateEntityId = this.PartyRoleId; // Aggregate Id
            var eventEntityId = e.PartyRoleEventId.PartyRoleId;

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

            if (stateVersion != eventVersion)
            {
                throw OptimisticConcurrencyException.Create(stateVersion, eventVersion, id.ToString());
            }
        }
Пример #2
0
 public virtual PartyRoleStateCreatedOrMergePatchedOrDeletedDto ToPartyRoleStateEventDto(IPartyRoleEvent stateEvent)
 {
     if (stateEvent.EventType == StateEventType.Created)
     {
         var e = (IPartyRoleStateCreated)stateEvent;
         return(ToPartyRoleStateCreatedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.MergePatched)
     {
         var e = (IPartyRoleStateMergePatched)stateEvent;
         return(ToPartyRoleStateMergePatchedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.Deleted)
     {
         var e = (IPartyRoleStateDeleted)stateEvent;
         return(ToPartyRoleStateDeletedDto(e));
     }
     throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType));
 }
Пример #3
0
 public void AddPartyRoleEvent(IPartyRoleEvent e)
 {
     _innerStateEvents.Add((PartyRoleStateCreatedOrMergePatchedOrDeletedDto)e);
 }