public async void GetCompare(string other) { using (HttpClient client = new HttpClient()) { PostData data = new PostData(); data.Add(Parameters.user); data.Add(Parameters.pass); data.Add(Parameters.username(AppSettings.Instance.Username)); data.Add(Parameters.other(other)); using (HttpResponseMessage response = await client.PostAsync(url + "GetCompare", data.ToStringContent())) { string resp = await response.Content.ReadAsStringAsync(); var jsonResponse = JsonConvert.DeserializeObject<Compare>(resp); G.Compare = jsonResponse; Messenger.Default.Send(new RefreshCompare()); } } }
public async void Login(string username, string password) { using (HttpClient client = new HttpClient()) { PostData data = new PostData(); data.Add(Parameters.user); data.Add(Parameters.pass); data.Add(Parameters.username(username)); data.Add(Parameters.password(password)); using (HttpResponseMessage response = await client.PostAsync(url + "Login", data.ToStringContent())) { string resp = await response.Content.ReadAsStringAsync(); if (resp == "1") { AppSettings.Instance.Username = username; Messenger.Default.Send(new LoggedIn()); } else { (Application.Current.Resources["Locator"] as ViewModelLocator).Main.ProgressVisibility = false; MessageDialog box = new MessageDialog("Hibás bejelentkezés!"); box.ShowAsync(); } } } }
public async void GetStandings() { using (HttpClient client = new HttpClient()) { PostData data = new PostData(); data.Add(Parameters.user); data.Add(Parameters.pass); using (HttpResponseMessage response = await client.PostAsync(url + "GetStandings", data.ToStringContent())) { string resp = await response.Content.ReadAsStringAsync(); var jsonResponse = JsonConvert.DeserializeObject<List<Standing>>(resp); G.Standings = jsonResponse; Messenger.Default.Send(new RefreshStandings()); } } }
public async void Bet(int matchID, string home, string away) { using (HttpClient client = new HttpClient()) { PostData data = new PostData(); data.Add(Parameters.user); data.Add(Parameters.pass); data.Add(Parameters.match_id(matchID)); data.Add(Parameters.home_score(home)); data.Add(Parameters.away_score(away)); data.Add(Parameters.username(AppSettings.Instance.Username)); using (HttpResponseMessage response = await client.PostAsync(url + "Bet", data.ToStringContent())) { string resp = await response.Content.ReadAsStringAsync(); if (resp == "1") { Messenger.Default.Send(new RefreshBet(matchID)); } else if (resp == "2") { Messenger.Default.Send(new ExpiredBet(matchID)); } } } }
public async Task<string> GetSetting(string key) { string ret = ""; using (HttpClient client = new HttpClient()) { PostData data = new PostData(); data.Add(Parameters.user); data.Add(Parameters.pass); data.Add(Parameters.key(key)); using (HttpResponseMessage response = await client.PostAsync(url + "GetSetting", data.ToStringContent())) { ret = await response.Content.ReadAsStringAsync(); } } return ret; }
public async void Register(string username, string password, string display_name) { using (HttpClient client = new HttpClient()) { PostData data = new PostData(); data.Add(Parameters.user); data.Add(Parameters.pass); data.Add(Parameters.username(username)); data.Add(Parameters.password(password)); data.Add(Parameters.display_name(display_name)); using (HttpResponseMessage response = await client.PostAsync(url + "Register", data.ToStringContent())) { string resp = await response.Content.ReadAsStringAsync(); if (resp == "1") { Messenger.Default.Send(new Registered()); } else { (Application.Current.Resources["Locator"] as ViewModelLocator).Main.ProgressVisibility = false; MessageDialog box = new MessageDialog("Hibás regisztráció!"); box.ShowAsync(); } } } }