public IActionResult GetFeaturedGame() { var game = GameCacheManager.GetFeaturedGameId(); if (game == null) { return(Ok(0)); } return(Ok(game)); }
public static void Main(string[] args) { GameCacheManager.Start(); CreateWebHostBuilder(args).Build().Run(); }
public async Task <IActionResult> GetBotsByUser(string Id) { var data = await _userManager.FindByIdAsync(User.Claims.FirstOrDefault(x => x.Type == "id")?.Value); if (data == null || data.Id.ToString() != Id) { var bots1 = _appDbContext.Bots.Where(x => x.IdentityId.ToString() == Id).OrderBy(x => x.Game).Select(x => new { x.Id, x.Name, x.Game, Active = GameCacheManager.IsBotActive(x.Id.ToString()), HighScore = _appDbContext.PacmanGames.Where(y => y.BotId.ToString() == x.Id.ToString()).DefaultIfEmpty().Max(y => y.Score) }); return(Ok(bots1)); } var bots = _appDbContext.Bots.Where(x => x.IdentityId == data.Id).OrderBy(x => x.Game).Select(x => new { x.Id, x.Name, x.PrivateKey, x.Game, Active = GameCacheManager.IsBotActive(x.Id.ToString()), HighScore = _appDbContext.PacmanGames.Where(y => y.BotId.ToString() == x.Id.ToString()).DefaultIfEmpty().Max(y => y.Score) }); return(Ok(bots)); }