public IActionResult AllExpiredGames()
        {
            // TODO: Refactor with SQL Join Statement
            IList <GameModel>    unformattedCurrentGames = gameDao.GetAllExpiredGames();
            IList <GameAPIModel> formattedGames          = new List <GameAPIModel>();

            foreach (GameModel game in unformattedCurrentGames)
            {
                GameAPIModel gameFormatted = FormatGameToApiModel(game);
                formattedGames.Add(gameFormatted);
            }


            return(new JsonResult(formattedGames));
        }
        public IActionResult MyGames(string userName)
        {
            // TODO: Refactor with SQL Join Statement
            int userId = userDao.GetUser(userName).Id;
            IList <GameModel>    unformattedCurrentGames = gameDao.GetMyGames(userId);
            IList <GameAPIModel> formattedGames          = new List <GameAPIModel>();

            foreach (GameModel game in unformattedCurrentGames)
            {
                GameAPIModel gameFormatted = FormatGameToApiModel(game);
                formattedGames.Add(gameFormatted);
            }

            return(new JsonResult(formattedGames));
        }
        public IActionResult GetGame(int id)
        {
            GameModel    gameUnformatted = gameDao.GetGameById(id);
            GameAPIModel gameFormatted   = new GameAPIModel();

            if (gameUnformatted == null)
            {
                return(NotFound());
            }
            else
            {
                gameFormatted = FormatGameToApiModel(gameUnformatted);
            }

            return(new JsonResult(gameFormatted));
        }
        private GameAPIModel FormatGameToApiModel(GameModel game)
        {
            GameAPIModel gameFormatted = new GameAPIModel();

            gameFormatted.GameId          = game.Id;
            gameFormatted.DateCreated     = game.DateCreated.ToString("d");
            gameFormatted.EndDate         = game.EndDate.ToString("g");
            gameFormatted.Name            = game.Name;
            gameFormatted.Description     = game.Description;
            gameFormatted.CreatorUsername = userDao.GetUser(game.CreatorId).Username;
            gameFormatted.CreatorId       = game.CreatorId;
            gameFormatted.NextDataUpdate  = DateTime.Now.AddMinutes(15);
            gameFormatted.LeaderboardData = BuildLeaderBoardData(game.Id);
            gameFormatted.IsCompleted     = game.IsCompleted;

            return(gameFormatted);
        }