public override ICommandResponse Handle(StartPeriodCommand command)
        {
            //Bout must be running
            var bout = _boutDataService.Load(command.BoutId);

            if (!_boutRunnerService.IsRunning(bout.BoutId))
            {
                throw new BoutNotRunningException(bout.BoutId);
            }

            //Game Must Be in pregame or halftime
            var state = _boutRunnerService.GetBoutState(command.BoutId);

            if (state.Phase != BoutPhase.Pregame && state.Phase != BoutPhase.Halftime)
            {
                return(new CommandResponse());
            }

            state.Phase = BoutPhase.Lineup;
            state.GameClock.Clear();

            var response = new UpdateBoutStateResponse(state);

            return(response);
        }
        public override ICommandResponse Handle(RunBoutCommand command)
        {
            var response = new CommandResponse();
            var bout     = _boutDataService.Load(command.BoutId);

            if (_boutRunnerService.IsRunning(bout.BoutId))
            {
                throw new BoutAlreadyRunningException(bout.BoutId);
            }

            _boutRunnerService.StartBout(bout);
            response.AddEvent(new BoutRunningEvent(bout.BoutId, bout.Name), Audiences.All);

            return(response);
        }
        public override ICommandResponse Handle(AddNodeToBoutCommand command)
        {
            var response = new CommandResponse();

            if (!_boutRunnerService.IsRunning(command.BoutId))
            {
                throw new BoutNotFoundException(command.BoutId);
            }

            var state = _boutRunnerService.GetBoutState(command.BoutId);
            var bout  = _boutData.Load(command.BoutId);


            _nodeService.AddToBout(command.NodeId, command.BoutId);
            response.AddEvent(new InitializeBoutEvent(bout, state), _nodeService.GetConnection(command.NodeId));
            response.AddEvent(new NodeJoinedBoutEvent(command.NodeId, command.BoutId), command.Originator);
            return(response);
        }