public void DispatchCommand(string matchId, string eventName) { if (eventName == "Zap") { _eventRepository.Empty(matchId); ZapSnapshots(matchId); return; } if (eventName == "Undo") { _eventRepository.UndoLastAction(matchId); UpdateSnapshots(matchId); return; } //TODO: this is a dirty hack DomainEvent domainEvent = default(DomainEvent); switch (eventName) { case "Start": domainEvent = new MatchStartedEvent(matchId); break; case "NewPeriod": domainEvent = new PeriodStartedEvent(matchId); break; case "Goal1": domainEvent = new HomeScoredGoalEvent(matchId); break; case "Goal2": domainEvent = new VisitorsScoredGoalEvent(matchId); break; case "EndPeriod": domainEvent = new PeriodEndedEvent(matchId); break; case "End": domainEvent = new MatchEndedEvent(matchId); break; } Bus.Send(domainEvent); UpdateSnapshots(matchId); }
public void Handle(PeriodEndedEvent message) { _repo.Save(message); }