Exemplo n.º 1
0
        private void Logout()
        {
            ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM;

            appvm.LoggedInCustomer = new Customer();
            appvm.ChangePage(new LoginScreenCustomerVM());
        }
Exemplo n.º 2
0
        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";
            }
        }
 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());
        }
Exemplo n.º 5
0
        public void FillInInformation()
        {
            ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM;

            LoggedInCustomer = appvm.LoggedInCustomer;
        }