// Want to be able to display games that each person has in common with other person // Should be able to also see playtimes of each person ???? (maybe) public async Task <IActionResult> GetGamesInCommon(string steamId1, string steamId2) { try { var gamesPlayedUser1 = await GetGamesPlayedByUser(steamId1, false); var gamesPlayedUser2 = await GetGamesPlayedByUser(steamId2, false); if (gamesPlayedUser1 == null || gamesPlayedUser2 == null) { if (gamesPlayedUser1 == null && gamesPlayedUser2 == null) { return(Content($"{steamId1} and {steamId2} both had issues retrieving data associated with their accounts.")); } if (gamesPlayedUser1 == null) { return(Content($"{steamId1} either has a private profile, steam user with that id does not exist, or some other error occurred.")); } if (gamesPlayedUser2 == null) { return(Content($"{steamId2} either has a private profile, steam user with that id does not exist, or some other error occurred.")); } } var gameInfos1 = gamesPlayedUser1.GameInfos; var gameInfos2 = gamesPlayedUser2.GameInfos; var gamesInCommonList = new List <CommonGame>(); // key is game name, int is hours of playtime var gameDict = new Dictionary <string, int>(); foreach (GameInfo gameInfo in gameInfos1) { gameDict.Add(gameInfo.GameName, gameInfo.GamePlaytime); } foreach (GameInfo gameInfo in gameInfos2) { if (gameDict.ContainsKey(gameInfo.GameName)) { CommonGame commonGame = new CommonGame { GameName = gameInfo.GameName, PlaytimeUser1 = gameDict[gameInfo.GameName], PlaytimeUser2 = gameInfo.GamePlaytime }; gamesInCommonList.Add(commonGame); } } var gamesInCommon = new GamesInCommon { SteamName1 = await GetSteamName(steamId1), SteamName2 = await GetSteamName(steamId2), CommonGames = gamesInCommonList }; return(View(gamesInCommon)); } catch { DebugLog("\nException Caught!"); DebugLog("From GetGamesInCommon"); return(Content("Error while calculating games that users share.")); } }