示例#1
0
        public void TesteGerarListaDeveloper()
        {
            IgdbService       igdb     = new IgdbService();
            DadosGameResponse response = igdb.DadosJogo(428).FirstOrDefault();

            List <DadosDeveloperPublisherResponse> devs = igdb.DadosDeveloperPublisher(response.Developers.ToArray());
            List <DadosDeveloperPublisherResponse> pubs = igdb.DadosDeveloperPublisher(response.Publishers.ToArray());

            GameDataView gameDataView = GameDataView.init();

            foreach (DadosDeveloperPublisherResponse dev in devs)
            {
                gameDataView.ListaDeveloper.Add(new developerPublisher {
                    name = dev.Name
                });
            }

            foreach (DadosDeveloperPublisherResponse pub in pubs)
            {
                gameDataView.ListaPublisher.Add(new developerPublisher {
                    name = pub.Name
                });
            }

            Assert.IsNotNull(gameDataView.ListaDeveloper);
            Assert.IsNotNull(gameDataView.ListaPublisher);
        }
示例#2
0
        public void TesteBuscarDadosJogosSerie()
        {
            IgdbService              igdb       = new IgdbService();
            DadosGameResponse        response   = igdb.DadosJogo(20044).FirstOrDefault();
            List <DadosGameResponse> listaGames = new List <DadosGameResponse>();

            if (response.Cover == null)
            {
                DadosGameSeriesResponse resposta = igdb.BuscaGameSeries(response.Collection).FirstOrDefault();
                foreach (int game in resposta.Games)
                {
                    DadosGameResponse dados = igdb.DadosJogo(game).FirstOrDefault();
                    if (igdb.ValidarGamePlataforma(dados))
                    {
                        listaGames.Add(igdb.DadosJogo(game).FirstOrDefault());
                    }
                }
            }
            Assert.IsNotNull(listaGames);
            Assert.IsNotNull(response.Collection);
        }
示例#3
0
        public void TesteBuscarDadosJogo()
        {
            IgdbService       igdb     = new IgdbService();
            DadosGameResponse response = igdb.DadosJogo(533).FirstOrDefault();

            Assert.IsNotNull(response.Id);
            Assert.IsNotNull(response.Name);
            Assert.IsNotNull(response.Developers);
            Assert.IsNotNull(response.Publishers);
            Assert.IsNotNull(response.Genres);
            Assert.IsNotNull(response.ReleaseDates);
            Assert.IsNotNull(response.Videos);
            Assert.IsNotNull(response.Cover.CloudinaryId);
        }
示例#4
0
        public void TesteSalvarJogoView()
        {
            IgdbService        igdb     = new IgdbService();
            DadosGameResponse  response = igdb.DadosJogo(428).FirstOrDefault();
            PlatformRepository pr       = new PlatformRepository();
            List <DadosDeveloperPublisherResponse> devs = igdb.DadosDeveloperPublisher(response.Developers.ToArray());
            List <DadosDeveloperPublisherResponse> pubs = igdb.DadosDeveloperPublisher(response.Publishers.ToArray());

            GameDataView gameDataView = GameDataView.init();

            gameDataView.Titulo      = response.Name;
            gameDataView.Descricao   = response.Summary;
            gameDataView.CloudnaryId = response.Cover.CloudinaryId;

            foreach (DadosDeveloperPublisherResponse dev in devs)
            {
                gameDataView.ListaDeveloper.Add(new developerPublisher {
                    name = dev.Name
                });
            }

            foreach (DadosDeveloperPublisherResponse pub in pubs)
            {
                gameDataView.ListaPublisher.Add(new developerPublisher {
                    name = pub.Name
                });
            }

            foreach (ReleaseDate lancamento in response.ReleaseDates)
            {
                platform plataforma = pr.GetPlatformByIgdb(lancamento.Platform);
                if (plataforma != null)
                {
                    DateTime data = new DateTime(1970, 1, 1, 0, 0, 0).AddMilliseconds(Convert.ToDouble(Convert.ToDouble(lancamento.Date)));
                    gameDataView.Platforms.Add(new game_platform {
                        id_platform  = plataforma.id,
                        release_date = data,
                        id_region    = lancamento.Region
                    });
                }
            }

            GameRepository gameRepository = new GameRepository();

            gameRepository.Adicionar(gameDataView);
        }
示例#5
0
        public void Teste()
        {
            GamesEntities        db    = new GamesEntities();
            IgdbService          igdb  = new IgdbService();
            List <game_platform> games = db.game_platform.Where(gp => gp.release_date == null).Where(gp => gp.id_status == 1).ToList();

            foreach (game_platform g in games)
            {
                GameEntity jogo = db.game.Find(g.id_game);
                try {
                    platform          plataforma = db.platform.Find(g.id_platform);
                    DadosGameResponse dados      = igdb.DadosJogo(jogo.id_igdb.Value).FirstOrDefault();
                    ReleaseDate       lancamento;
                    if (g.id_region == null)
                    {
                        lancamento = dados.ReleaseDates.Where(r => r.Region == 8).Where(r => r.Platform == plataforma.id_igdb).FirstOrDefault();
                        if (lancamento == null)
                        {
                            lancamento = dados.ReleaseDates.Where(r => r.Region == 2).Where(r => r.Platform == plataforma.id_igdb).FirstOrDefault();
                        }
                        if (lancamento != null)
                        {
                            g.id_region = lancamento.Region;
                        }
                    }
                    else
                    {
                        lancamento = dados.ReleaseDates.Where(r => r.Region == g.id_region).Where(r => r.Platform == plataforma.id_igdb).FirstOrDefault();
                        if (lancamento == null)
                        {
                            lancamento = dados.ReleaseDates.Where(r => r.Region == 8).Where(r => r.Platform == plataforma.id_igdb).FirstOrDefault();
                        }
                        if (lancamento == null)
                        {
                            lancamento = dados.ReleaseDates.Where(r => r.Region == 2).Where(r => r.Platform == plataforma.id_igdb).FirstOrDefault();
                        }
                        if (lancamento == null)
                        {
                            if (plataforma.id != 7)
                            {
                                lancamento = dados.ReleaseDates.Where(r => r.Region == 8).Where(r => r.Platform == 45).FirstOrDefault();
                                if (lancamento == null)
                                {
                                    lancamento = dados.ReleaseDates.Where(r => r.Region == 2).Where(r => r.Platform == 45).FirstOrDefault();
                                }
                            }
                        }
                    }
                    if (lancamento != null)
                    {
                        if (lancamento.Date != null)
                        {
                            DateTime data = new DateTime(1970, 1, 1, 0, 0, 0).AddMilliseconds(Convert.ToDouble(Convert.ToDouble(lancamento.Date)));
                            g.release_date    = data;
                            db.Entry(g).State = EntityState.Modified;
                        }
                    }
                }
                catch (Exception ex) {
                    Console.Write(jogo.name + " " + ex.Message);
                }
            }
            db.SaveChanges();
        }
示例#6
0
        public async Task <ActionResult> PreencherDadosGameIgdbJquery(int id_igdb, int Id = 0)
        {
            IgdbService       igdb     = new IgdbService();
            DadosGameResponse response = igdb.DadosJogo(id_igdb).FirstOrDefault();
            List <DadosDeveloperPublisherResponse> devs = new List <DadosDeveloperPublisherResponse>();
            List <DadosDeveloperPublisherResponse> pubs = new List <DadosDeveloperPublisherResponse>();
            List <DadosGenreResponse> genres            = new List <DadosGenreResponse>();
            List <ReleaseDate>        lancamentos       = new List <ReleaseDate>();

            PlatformRepository pr = new PlatformRepository();

            if (response.Developers != null && response.Developers.Count > 0)
            {
                devs = igdb.DadosDeveloperPublisher(response.Developers.ToArray());
            }
            if (response.Publishers != null && response.Publishers.Count > 0)
            {
                pubs = igdb.DadosDeveloperPublisher(response.Publishers.ToArray());
            }
            if (response.Genres != null && response.Genres.Count > 0)
            {
                genres = igdb.DadosGenre(response.Genres.ToArray());
            }
            if (response.ReleaseDates != null && response.ReleaseDates.Count > 0)
            {
                lancamentos = response.ReleaseDates;
            }

            GameDataView gameDataView = GameDataView.GetGameDataView();

            gameDataView.Id        = Id;
            gameDataView.id_igdb   = id_igdb;
            gameDataView.Titulo    = response.Name;
            gameDataView.Descricao = response.Summary;

            if (response.Cover != null)
            {
                gameDataView.Imagem      = gameDataView.BigCoverUrl + response.Cover.CloudinaryId + ".jpg";
                gameDataView.CloudnaryId = response.Cover.CloudinaryId;
            }
            else
            {
                gameDataView.Imagem = "/Content/ps.png";
            }

            gameDataView.InitListas();

            foreach (DadosDeveloperPublisherResponse dev in devs)
            {
                gameDataView.ListaDeveloper.Add(new developerPublisher {
                    name    = dev.Name,
                    id_igdb = dev.Id
                });
            }

            foreach (DadosDeveloperPublisherResponse pub in pubs)
            {
                gameDataView.ListaPublisher.Add(new developerPublisher {
                    name    = pub.Name,
                    id_igdb = pub.Id
                });
            }

            foreach (DadosGenreResponse genre in genres)
            {
                gameDataView.ListaGenre.Add(new genre {
                    id_igdb = genre.Id,
                    name    = genre.Name
                });
            }

            try {
                var buscaMetacritic = await Metacritic.SearchFor().Games().UsingTextAsync(response.Name);

                foreach (ReleaseDate lancamento in lancamentos)
                {
                    platform plataforma = pr.GetPlatformByIgdb(lancamento.Platform);
                    int?     meta       = null;
                    if (plataforma != null)
                    {
                        string sigla;
                        switch (plataforma.sigla)
                        {
                        case "PS1":
                            sigla = "PS";
                            break;

                        case "PSVITA":
                            sigla = "VITA";
                            break;

                        default:
                            sigla = plataforma.sigla;
                            break;
                        }

                        var resultado = buscaMetacritic.Where(m => m.Platform == sigla).Where(m => m.Name.ToLowerInvariant() == response.Name.ToLowerInvariant()).FirstOrDefault();
                        if (resultado != null)
                        {
                            meta = resultado.Score;
                        }

                        DateTime data = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(Convert.ToDouble(Convert.ToDouble(lancamento.Date)));
                        gameDataView.Platforms.Add(new game_platform {
                            id_platform  = plataforma.id,
                            release_date = data,
                            metacritic   = meta,
                            id_region    = lancamento.Region
                        });
                    }
                }
            }
            catch (Exception ex) {
            }

            return(PartialView("FormGameView", gameDataView));
        }
示例#7
0
        public void AtualizarTudoIgdb()
        {
            GamesEntities db   = new GamesEntities();
            IgdbService   igdb = new IgdbService();
            DeveloperPublisherRepository developerPublisherRepository = new DeveloperPublisherRepository();
            GenreRepository genreRepository = new GenreRepository();

            var lista = db.game;

            foreach (var game in lista)
            {
                if (game.id_igdb != null)
                {
                    DadosGameResponse dados = igdb.DadosJogo((int)game.id_igdb).FirstOrDefault();
                    game.summary = dados.Summary;
                    if (dados.Developers != null)
                    {
                        foreach (var dev in dados.Developers)
                        {
                            var id_dev = developerPublisherRepository.GetIdByIgdb(dev, igdb.DadosDeveloperPublisher(new int[] { dev }).FirstOrDefault().Name);
                            var devs   = db.game_developerPublisher.Where(g => g.id_game == game.id && g.id_developerPublisher == id_dev && g.tipo == 1).Any();
                            if (!devs)
                            {
                                game.game_developerPublisher.Add(new game_developerPublisher {
                                    id_developerPublisher = id_dev, id_game = game.id, tipo = 1
                                });
                            }
                        }
                    }
                    if (dados.Publishers != null)
                    {
                        foreach (var pub in dados.Publishers)
                        {
                            var id_pub = developerPublisherRepository.GetIdByIgdb(pub, igdb.DadosDeveloperPublisher(new int[] { pub }).FirstOrDefault().Name);
                            var pubs   = db.game_developerPublisher.Where(g => g.id_game == game.id && g.id_developerPublisher == id_pub && g.tipo == 2).Any();
                            if (!pubs)
                            {
                                game.game_developerPublisher.Add(new game_developerPublisher {
                                    id_developerPublisher = id_pub, id_game = game.id, tipo = 2
                                });
                            }
                        }
                    }
                    if (dados.Genres != null)
                    {
                        foreach (var genre in dados.Genres)
                        {
                            var id_genre = genreRepository.GetIdByIgdb(genre, igdb.DadosGenre(new int[] { genre }).FirstOrDefault().Name);
                            var genres   = db.game_genre.Where(g => g.id_game == game.id && g.id_genre == id_genre).Any();
                            if (!genres)
                            {
                                game.game_genre.Add(new game_genre {
                                    id_genre = id_genre, id_game = game.id
                                });
                            }
                        }
                    }
                }
            }
            db.SaveChanges();
        }