Beispiel #1
0
        protected object JSONGetScoreKeeperSchedule(string data, Dictionary <string, object> sessionData)
        {
            Dictionary <string, object> schedule = new Dictionary <string, object>();

            string accessCode = getAccessCode(sessionData);

            CourtRound currentCourtRound    = getCurrentCourtRound(accessCode);
            int?       currentCourtRoundNum = null;

            if (currentCourtRound != null)
            {
                currentCourtRoundNum = currentCourtRound.RoundNumber;
            }

            List <int> startableCourtRoundNums = new List <int>();

            int?       activeCourtRoundNum = null;
            CourtRound activeCourtRound    = Controller.Tournament.ActiveCourtRound;

            if (activeCourtRound != null)
            {
                activeCourtRoundNum = activeCourtRound.RoundNumber;
            }

            if (Controller.Tournament != null)
            {
                foreach (CourtRound courtRound in Controller.Tournament.CourtRounds)
                {
                    string key = courtRound.RoundNumber.ToString();
                    object value;
                    Game   courtRoundGame = getGameInCourtRoundForAccessCode(courtRound, accessCode);
                    if (courtRoundGame != null && courtRoundGame.Enabled)
                    {
                        value = new GameWebData(courtRoundGame);

                        //This game can be manually started
                        if (!courtRoundGame.IsCompleted)
                        {
                            startableCourtRoundNums.Add(courtRound.RoundNumber);
                        }
                    }
                    else
                    {
                        value = new { NotAssigned = true }
                    };

                    schedule.Add(key, value);
                }
            }

            return
                (new
            {
                Schedule = schedule,
                CurrentCourtRoundNum = currentCourtRoundNum,
                ActiveCourtRoundNum = activeCourtRoundNum,
                StartableCourtRoundNums = startableCourtRoundNums
            });
        }
Beispiel #2
0
        protected object JSONGetCurrentGame(string data, Dictionary <string, object> sessionData)
        {
            Game game          = null;
            bool gameCompleted = false;
            bool notAssigned   = false;
            int? currentRound  = null;

            if (Controller.Tournament != null)
            {
                CourtRound activeCourtRound = Controller.Tournament.ActiveCourtRound;
                if (activeCourtRound != null)
                {
                    Game activeCourtRoundGame = getGameInCourtRoundForAccessCode(activeCourtRound, getAccessCode(sessionData));
                    if (activeCourtRoundGame != null && !activeCourtRoundGame.IsCompleted)
                    {
                        game = activeCourtRoundGame;
                    }
                    else
                    {
                        notAssigned = activeCourtRoundGame == null;
                        if (activeCourtRoundGame != null)
                        {
                            gameCompleted = activeCourtRoundGame.IsCompleted;
                        }
                        currentRound = activeCourtRound.RoundNumber;
                    }
                }
            }


            object gameData = null;

            if (game != null && game.Enabled)
            {
                gameData = new GameWebData(game);
            }
            else
            {
                gameData = new { NotAssigned = notAssigned, GameCompleted = gameCompleted, CourtRoundNum = currentRound }
            };

            return(gameData);
        }
Beispiel #3
0
        protected object JSONGetGame(string data, Dictionary <string, object> sessionData)
        {
            Game game = null;

            int id;

            if (int.TryParse(data, out id))
            {
                game = getGameFromId(id);
            }
            else
            {
                throw new HttpException(400, "Bad Request");
            }

            GameWebData gameData = null;

            if (game != null)
            {
                gameData = new GameWebData(game);
            }

            return(gameData);
        }