private void button1_Click(object sender, EventArgs e) { Task.Run(() => { int idJoueur; Task <string> result = Requetes.PostInfo(Properties.Settings.Default.SERVER.ToString() + "/Joueur/Ajouter", new List <AttributeModel> { new AttributeModel("idUtil", idUtil), new AttributeModel("idPartie", idPartie) }); this.Invoke(new MethodInvoker(delegate { idJoueur = Convert.ToInt32(result.Result); Task <string> result2 = Requetes.PostInfo(Properties.Settings.Default.SERVER.ToString() + "/Personnage/Ajouter", new List <AttributeModel> { new AttributeModel("idJoueur", idJoueur), new AttributeModel("idClasse", select_classe.SelectedIndex + 1), new AttributeModel("nom", nom_perso.Text), new AttributeModel("prenom", prenom_perso.Text), new AttributeModel("description", desc_perso.Text), new AttributeModel("vie", ClasseJson[select_classe.SelectedIndex]["MAX_VIE"].ToString()), new AttributeModel("mana", ClasseJson[select_classe.SelectedIndex]["MAX_MANA"].ToString()) }); window.ChangerNomPerso(nom_perso.Text); window.Show(); this.Close(); })); }); }
private void searchGameBtn_Click(object sender, EventArgs e) { string idPartieSearch = txtIdGame.Text; if (!String.IsNullOrEmpty(idPartieSearch)) { Task.Run(() => { Task <string> result = Requetes.GetInfo(server + "/Partie/GetById?idPartie=" + idPartieSearch); Task <string> resultTestPartie = Requetes.GetInfo(server + "/Partie/EstDansLaPartie?idPartie=" + idPartieSearch + "&idUtil=" + IdUtilisateur); this.Invoke(new MethodInvoker(delegate { int isDansPartie = -1; JObject json = JObject.Parse(result.Result); if (json["Message"] == null) { if (Int32.TryParse(resultTestPartie.Result, out isDansPartie)) { if (isDansPartie == 0) { RejoindrePartie p = new RejoindrePartie(json, IdUtilisateur, this); this.Hide(); p.Show(); } else { MessageBox.Show("Vous avez déjà rejoint cette partie."); } } } else { MessageBox.Show("Aucune partie trouvée."); } })); }); } }