public ActionResult Index() { var api = GoPlayApi.Instance; var gameModel = new GamesViewModel(); gameModel.featuredGames = api.getFeaturedGames().Data; gameModel.popularGames = api.GetGamesByIds(true, false, true).Data; return View(gameModel); }
public ActionResult GetGames(int page = 1) { var api = GoPlayApi.Instance; var gameModel = new GamesViewModel(); int per_page; if (!int.TryParse(ConfigurationManager.AppSettings["GAME_PER_PAGE"], out per_page)) { per_page = 12; } int count = 0; var gamesTotal = Helpers.GameHelper.GetGamesForCurrentUser(CurrentUser); count = gamesTotal.Count; gameModel.games = Helpers.GameHelper.getGamesPerPageForCurrentUser(page, per_page, CurrentUser, gamesTotal); gameModel.pagination = new Pagination(page, per_page, count); gameModel.genres = Helpers.GameHelper.getLocalizedField(gamesTotal, "genre"); IPAddress clientIp = Request.GetClientIp(); gameModel.games.ForEach(g => { g.genre = GameHelper.getLocalized(g, "genre"); g.isComingSoon = GameHelper.isComingSoon(g, CurrentUser, clientIp); JObject platforms = GameHelper.getDownloadLinksForCurrentUser(g, CurrentUser, clientIp); if (platforms != null && platforms.Properties().Any()) { Dictionary<string, string> links = new Dictionary<string, string>(); foreach (var item in platforms.Properties()) { links[item.Name] = item.Value.ToString(); } g.platforms = links; } }); return Json(new { data = gameModel }); }
// GET: Main public ActionResult Index() { var api = GoPlay.Core.GoPlayApi.Instance; string limitComingGameConfig = ConfigurationManager.AppSettings["LIMIT_COMING_GAME"]; int limitComingGame = 0; if (!int.TryParse(limitComingGameConfig, out limitComingGame)) limitComingGame = 3; string limitFeatureGameConfig = ConfigurationManager.AppSettings["LIMIT_FEATURE_GAME"]; int limitFeatureGame = 0; if (!int.TryParse(limitFeatureGameConfig, out limitFeatureGame)) limitFeatureGame = 5; string popularGameConfig = ConfigurationManager.AppSettings["POPULAR_GAMES"]; List<int> popularGames; if (string.IsNullOrEmpty(popularGameConfig)) popularGames = new List<int> { 42, 33, 20, 31, 55, 49 }; else popularGames = popularGameConfig.Split(',').Select(i=> Convert.ToInt32(i)).ToList(); var gameModel = new GamesViewModel(); IPAddress ip = WebIpHelper.GetClientIp(Request); gameModel.games = Helpers.GameHelper.getCommingGames(CurrentUser, ip, 3); var featuredGames = api.getFeaturedGames(); if (!featuredGames.HasData) { gameModel.featuredGames = Helpers.GameHelper.GetGamesForCurrentUser(CurrentUser).Take(5).ToList(); } else { gameModel.featuredGames = featuredGames.Data; } gameModel.popularGames = api.GetGamesByIds(true, false, popularGames).Data; return View(gameModel); }