public void PushGameRatingTest()
        {
            int        newRatingId;
            GameRating test = new GameRating();

            newRatingId = dao.PushGameRating(9000, 51, 23, 55);
            test        = dao.PullGameRating(newRatingId);
            Assert.AreEqual(rtingID + 1, test.Rating_Id);
            Assert.AreEqual(51, test.Game_popularity);
        }
Esempio n. 2
0
        public IList <GameInfo> PullMuliGameInfo(string gameName)
        {
            //Creates a new list of games
            IList <GameInfo> pulledGames = new List <GameInfo>();

            //Setting our query string up for IGDB  **TODO Clean up query
            gameName = "search " + "\"" + gameName + "\"" + ";fields * ;";
            //Creates IGDB client using our apiKey
            var igdb = IGDB.Client.Create(Environment.GetEnvironmentVariable(apiKey));

            igdb.ApiKey = apiKey;
            //Queries IGDB and pulls all the game info then creates a GameInfo class and sets the values then returns it all as a list of games
            var games = Task.Run(() => igdb.QueryAsync <Game>(IGDB.Client.Endpoints.Games, query: gameName)).Result;

            //Converts values that are null to 0
            for (int i = 0; i < games.Count(); i++)
            {
                int?popularity = (int?)games[i].Popularity;
                if (popularity == null)
                {
                    popularity = 0;
                }
                int?totalRating = (int?)games[i].TotalRating;
                if (totalRating == null)
                {
                    totalRating = 0;
                }
                int?totalRatingCount = (int?)games[i].TotalRatingCount;
                if (totalRatingCount == null)
                {
                    totalRatingCount = 0;
                }
                int?hype = (int?)games[i].Hypes;
                if (hype == null)
                {
                    hype = 0;
                }

                //Ratings are only available from querying games on IGDB, Ratings are only available by querying games from IGDB, putting it here reduces amount of queries
                int      newRatingId = daoPushRating.PushGameRating((int)hype, (int)popularity, (int)totalRating, (int)totalRatingCount);
                GameInfo newGame     = new GameInfo
                {
                    coverID         = (int)games[i].Cover.Id,
                    franchiseID     = (int)games[i].Franchise.Id,
                    gameDescription = (string)games[i].Summary,
                    gameName        = (string)games[i].Name,
                    game_ID         = (int)games[i].Id,
                    genreID         = games[i].Genres.Ids.Select(x => (int)x).ToArray(),
                    platformID      = games[i].Platforms.Ids.Select(x => (int)x).ToArray(),
                    ratingId        = newRatingId
                };
                pulledGames.Add(newGame);
            }
            return(pulledGames);
        }