private async void ScanCustomer() { BEID_EIDCard card = IDReader.getData(); if (card == null) { MessageBox.Show("Sluit de id-reader aan en steek de kaart er correct in", "Niet correct aangesloten"); } else { if (!addCustomer(card)) { MessageBox.Show("Sluit de id-reader aan en steek de kaart er correct in", "Niet correct aangesloten"); return; } ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM; if (await checkCustomerExists()) { appvm.ChangePage(new ChargingVM()); } else { appvm.ChangePage(new RegisterVM()); } } }
private async void RegisterCustomer() { string input = JsonConvert.SerializeObject(Customer); using (HttpClient client = new HttpClient()) { client.SetBearerToken(ApplicationVM.token.AccessToken); HttpResponseMessage response = await client.PostAsync("http://localhost:55853/api/customer", new StringContent(input, Encoding.UTF8, "application/json")); if (response.IsSuccessStatusCode) { string output = await response.Content.ReadAsStringAsync(); ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM; appvm.ChangePage(new ChargingVM()); } else { Console.WriteLine("error"); } } }