/// <summary> /// Get a Game by GameID /// </summary> /// <param name="id">GameID</param> /// <returns>Game</returns> public async Task <GameDto> GetGameById(Guid id, string token) { Game game = await _repo.GetGameById(id); if (game == null) { return(null); } Team homeTeam = new Team(); Team awayTeam = new Team(); using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var response = await httpClient.GetAsync($"http://20.62.247.144/api/Team/{game.HomeTeamID}"); var apiResponse = await response.Content.ReadAsStringAsync(); homeTeam = JsonConvert.DeserializeObject <Team>(apiResponse); response = await httpClient.GetAsync($"http://20.62.247.144/api/Team/{game.AwayTeamID}"); apiResponse = await response.Content.ReadAsStringAsync(); awayTeam = JsonConvert.DeserializeObject <Team>(apiResponse); } GameDto gameDto = new GameDto { GameID = game.GameID, GameDate = game.GameDate, HomeScore = game.HomeScore, AwayScore = game.AwayScore, AwayTeam = awayTeam, HomeTeam = homeTeam, HomeTeamID = game.HomeTeamID, AwayTeamID = game.AwayTeamID, SeasonID = game.SeasonID, WinningTeamID = game.WinningTeam }; if (game.WinningTeam == game.AwayTeamID) { gameDto.WinningTeam = awayTeam; } if (game.WinningTeam == game.HomeTeamID) { gameDto.WinningTeam = homeTeam; } return(gameDto); }