Exemplo n.º 1
0
        static public async Task<UserRP> MakeCall(string method, UserVM obj)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:3000/");
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = await client.PostAsJsonAsync(method, obj);

                if (response.IsSuccessStatusCode)
                {
                    string res = await response.Content.ReadAsStringAsync();
                    UserRP f = JsonConvert.DeserializeObject<UserRP>(res);

                    return f;
                }
            }

            return null;
        }
Exemplo n.º 2
0
        private async void edit_Click(object sender, RoutedEventArgs e)
        {
            bool isSuccess = false;

            MessageDialog result;

            if (username.Text != "" && email.Text != "" && password.Password != "")
            {
                UserVM user = new UserVM(email.Text, password.Password, username.Text);
                user.userID = GlobalData.id;
                UserRP res = await ApiCall.MakeCall("editProfil", user);

                isSuccess = res.success;
            }

            if (isSuccess)
            {
                result = new MessageDialog("Your account has been modified successfully !");
            }
            else
            {
                result = new MessageDialog("Error: Your information couldn't be modified.");
            }
            await result.ShowAsync();
        }