private async void Confirm()
        {
            try
            { ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM;
              appvm.LoggedInCustomer = NewCustomer;
              string input = JsonConvert.SerializeObject(NewCustomer);
              TestCustomer = (from p in Customers where p.Barcode == NewCustomer.Barcode select p).First();
              if (TestCustomer == null)
              {
                  using (HttpClient client = new HttpClient())
                  {
                      HttpResponseMessage response = await client.PostAsync("http://localhost:41983/api/CustomerTerminal", new StringContent(input, Encoding.UTF8, "application/json"));

                      if (response.IsSuccessStatusCode)
                      {
                          string output = await response.Content.ReadAsStringAsync();
                      }
                      else
                      {
                          MessageBox.Show("could not save customer");
                      }
                  }
                  appvm.ChangePage(new PageThreeVM());
              }
              else if (TestCustomer.Active == false)
              {
                  using (HttpClient client = new HttpClient())
                  {
                      HttpResponseMessage response = await client.PutAsync("http://localhost:41983/api/ExistingCustomer", new StringContent(input, Encoding.UTF8, "application/json"));

                      if (response.IsSuccessStatusCode)
                      {
                          string output = await response.Content.ReadAsStringAsync();
                      }
                      else
                      {
                          MessageBox.Show("could not save customer");
                      }
                  }
                  appvm.ChangePage(new PageThreeVM());
              }

              else
              {
                  MessageBox.Show("Failed to create new customer");
              } }
            catch (Exception ex)
            {
                Error = "Couldn't create new customer";
            }
        }
Exemple #2
0
        private void Logout()
        {
            ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM;

            appvm.LoggedInCustomer = new Customer();
            appvm.ChangePage(new LoginScreenCustomerVM());
        }
 private void Login()
 {
     try
     {
         LoggedInCustomer = (from p in Customers where p.Barcode == Barcode select p).First();
         if (LoggedInCustomer != null)
         {
             ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM;
             appvm.LoggedInCustomer = LoggedInCustomer;
             appvm.ChangePage(new PageThreeVM());
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Could not scan customer, is the customer registered?");
     }
 }
        private void RegisterCustomer()
        {
            ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM;

            appvm.ChangePage(new PageTwoVM());
        }