public List <int> GetUsersGameRooms(int userId) { List <int> gameIds = new List <int>(); List <IGame> allGames = _gameService.GetAllGames(); if (allGames != null) { allGames.ForEach(game => { game.GetPlayersInRoom().ForEach(p => { if (p.user.Id() == userId) { gameIds.Add(game.Id); } }); game.GetSpectetorInRoom().ForEach(s => { if (s.user.Id() == userId) { gameIds.Add(game.Id); } }); }); } return(gameIds); }
public List <int> GetAllGamesId() { var allGames = _gameService.GetAllGames(); return(GamesToIds(allGames)); }