Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public void Handle(VisitorsScoredGoalEvent message)
 {
     _repo.Save(message);
 }