public async Task <ChampionsEntity> GetChampion(int?id) { ChampionsEntity champions = new ChampionsEntity(); try { if (id.HasValue) { HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, url + "GetChampion"); requestMessage.Headers.Add("id", id.ToString()); HttpResponseMessage response = await client.SendAsync(requestMessage); if (response.IsSuccessStatusCode) { var responseStr = await response.Content.ReadAsStringAsync(); champions = JsonConvert.DeserializeObject <ChampionsEntity>(responseStr); } else { champions.Error = true; } } } catch (Exception) { champions = new ChampionsEntity(); champions.Error = true; } return(champions); }
public async Task <ActionResult> Details(int id) { ChampionsEntity champions = new ChampionsEntity(); try { AlreadyLoggedIn(); champions = await _services.GetChampion(id); if (champions.Error) { return(RedirectToAction("ErrorPage")); } } catch (Exception) { return(RedirectToAction("ErrorPage")); } return(View(champions)); }