public async Task <CatanGame> GetGame(Guid gameId) { _logger?.LogDebug($"GetGame: {gameId}"); IAsyncCursor <CatanGame> catanGameCursor = await MongoCollection.FindAsync(game => game.Id == gameId); return(catanGameCursor.First()); }
/* * Asyncronously loads a user from the database via license * @Param string * @Param string */ public async Task <Profile> LoadByLicenseAsync <T>(string table, string license) { IMongoCollection <Profile> collection = (IMongoCollection <Profile>)database.GetCollection <T>(table); FilterDefinition <Profile> filter = Builders <Profile> .Filter.Eq("license", license); IAsyncCursor <Profile> cursor = await collection.FindAsync(filter); return(cursor.First()); }
public async Task <int> GetGameTotalActiveKnights(Guid catanGameId) { _logger?.LogDebug($"GetGameTotalActiveKnights: {catanGameId}"); IAsyncCursor <CatanGame> catanGameCursor = await MongoCollection.FindAsync(game => game.Id == catanGameId); CatanGame catanGame = catanGameCursor.First(); if (catanGame == null) { _logger.LogError($"GetGameTotalActiveKnights: couldn't find game at this id:{catanGameId}"); } return(catanGame.ActivePlayers.Sum(activePlayer => activePlayer.NumOfActiveKnights)); }