예제 #1
0
        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());
                }
            }
        }
예제 #2
0
        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();
                    }
                }
            }
        }
예제 #3
0
        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());
                }
            }
        }
예제 #4
0
        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));
                    }
                }
            }
        }
예제 #5
0
        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;
        }
예제 #6
0
        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();
                    }
                }
            }
        }