private async void PostValue() { double amount = ApplicationVM.ActiveUser.Balance + TotalAmount; CustomerTransaction ct = new CustomerTransaction() { RijksregisterNummer = ApplicationVM.ActiveUser.RijksregisterNummer, VerschilBedrag = amount }; string input = JsonConvert.SerializeObject(ct); using (HttpClient client = new HttpClient()) { client.SetBearerToken(ApplicationVM.Token.AccessToken); HttpResponseMessage response = await client.PostAsync("http://localhost:3655/api/customertransaction/", new StringContent(input, Encoding.UTF8, "application/json")); if (response.IsSuccessStatusCode) { ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM; ApplicationVM.ActiveUser.Balance = amount; appvm.ChangePage(new MainscreenVM()); } else { Error = "Transactie mislukt"; CreateErrorlog(Error, "OpladenVM", "PostValue"); } } }
private async void Register() { string input = JsonConvert.SerializeObject(ApplicationVM.TempUser); using (HttpClient client = new HttpClient()) { client.SetBearerToken(ApplicationVM.Token.AccessToken); HttpResponseMessage response = await client.PutAsync("http://localhost:3655/api/Customer/", new StringContent(input, Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { Console.WriteLine("error"); } else { ApplicationVM.ActiveUser = ApplicationVM.TempUser; ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM; appvm.ChangePage(new MainscreenVM()); } } }
private async void ControleerGebruiker(Customer c) { using (HttpClient client = new HttpClient()) { client.SetBearerToken(ApplicationVM.Token.AccessToken); HttpResponseMessage response = await client.GetAsync("http://localhost:3655/Api/Customer/?nummer=" + c.RijksregisterNummer); string json = await response.Content.ReadAsStringAsync(); ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM; if (json != "null") { ApplicationVM.ActiveUser = JsonConvert.DeserializeObject <Customer>(json); appvm.ChangePage(new MainscreenVM()); } else { appvm.ChangePage(new RegistrerenVM()); } } }