public void Dispatch(ILotEvent e) { foreach (var handler in this.handlers) { handler.Handle(e); } }
protected void ThrowOnWrongEvent(ILotEvent e) { var id = new System.Text.StringBuilder(); id.Append("[").Append("Lot|"); var stateEntityId = this.LotId; // Aggregate Id var eventEntityId = e.LotEventId.LotId; 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.LotEventId.Version; if (stateVersion != eventVersion) { throw OptimisticConcurrencyException.Create(stateVersion, eventVersion, id.ToString()); } }
public virtual LotStateCreatedOrMergePatchedOrDeletedDto ToLotStateEventDto(ILotEvent stateEvent) { if (stateEvent.EventType == StateEventType.Created) { var e = (ILotStateCreated)stateEvent; return(ToLotStateCreatedDto(e)); } else if (stateEvent.EventType == StateEventType.MergePatched) { var e = (ILotStateMergePatched)stateEvent; return(ToLotStateMergePatchedDto(e)); } else if (stateEvent.EventType == StateEventType.Deleted) { var e = (ILotStateDeleted)stateEvent; return(ToLotStateDeletedDto(e)); } throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType)); }
public void Handle(ILotEvent e) { this.Event = e; }
public void AddLotEvent(ILotEvent e) { _innerStateEvents.Add((LotStateCreatedOrMergePatchedOrDeletedDto)e); }