public ActionResult Partie(int id) { partielModel = new PartieViewModel(); HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:56063/"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = client.GetAsync("api/house/GetHouseById/" + id).Result; if (response.IsSuccessStatusCode) { partielModel.House = response.Content.ReadAsAsync <IndexViewModel>().Result; } HttpResponseMessage response1 = client.GetAsync("api/house/GetRandomHouses").Result; if (response1.IsSuccessStatusCode) { partielModel.RandHouses = response1.Content.ReadAsAsync <List <IndexViewModel> >().Result; } return(View(partielModel)); }
public PartieViewModel getPartieEnCours(int id, int id_ami) { Partie partieEnCours = _partieService.getPartieEnCours(id, id_ami); List <MancheViewModel> mesmanches = new List <MancheViewModel>(); foreach (Manche m in partieEnCours.Manches) { mesmanches.Add(new MancheViewModel(m.theme.id, m.theme.text, m.s1, m.s2)); } PartieViewModel mapartie = new PartieViewModel(partieEnCours.id, partieEnCours.j1.id, partieEnCours.j2.id, partieEnCours.j1.name, partieEnCours.j2.name, partieEnCours.s1, partieEnCours.s2, partieEnCours.player, mesmanches); return(mapartie); }