public ActionResult AdicionarPlataformaJquery() { GameDataView view = GameDataView.GetGameDataView(); view.Platforms.Add(new game_platform()); return(PartialView("PlatformStatusView", view)); }
public ActionResult RemoverPlataformaJquery(int index) { GameDataView view = GameDataView.GetGameDataView(); view.Platforms.RemoveAt(index); return(PartialView("PlatformStatusView", view)); }
private void ExcluirImagens(int id, string cloudnary_id) { GameDataView view = GameDataView.GetGameDataView(); File.Delete(view.Imagesfolder + id + "_BigCover_" + cloudnary_id + ".jpg"); File.Delete(view.Imagesfolder + id + "_BigCover2x_" + cloudnary_id + ".jpg"); File.Delete(view.Imagesfolder + id + "_SmallCover_" + cloudnary_id + ".jpg"); File.Delete(view.Imagesfolder + id + "_MicroCover2x_" + cloudnary_id + ".jpg"); }
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)); }