Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public void TesteBuscarDadosDeveloperPublisher()
        {
            IgdbService igdb = new IgdbService();

            int[] devs = { 250, 400 };
            List <DadosDeveloperPublisherResponse> response = igdb.DadosDeveloperPublisher(devs);

            Assert.IsNotNull(response[0].Id);
            Assert.IsNotNull(response[0].Name);
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
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();
        }