コード例 #1
0
        private async void SaveSales()
        {
            ProductList p        = new ProductList();
            double      verschil = ApplicationVM.ActiveCustomer.Balance - TotalCost;

            p.CustomerTransaction = new CustomerTransaction()
            {
                RijksregisterNummer = ApplicationVM.ActiveCustomer.RijksregisterNummer, VerschilBedrag = verschil
            };
            p.Products   = SelectedProducts;
            p.CustomerID = ApplicationVM.ActiveCustomer.ID;
            p.RegisterID = int.Parse(Properties.Settings.Default.RegisterID);
            p.TimeStamp  = DateTime.Now;
            string input = JsonConvert.SerializeObject(p);

            using (HttpClient client = new HttpClient())
            {
                client.SetBearerToken(ApplicationVM.Token.AccessToken);
                HttpResponseMessage response = await client.PostAsync("http://localhost:3655/api/sales", new StringContent(input, Encoding.UTF8, "application/json"));

                if (response.IsSuccessStatusCode)
                {
                    ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM;
                    ApplicationVM.ActiveCustomer = new Customer();
                    appvm.ChangePage(new TussenpaginaVM());
                }
                else
                {
                    Error = "Transactie mislukt";
                    CreateErrorlog(Error, "MainscreenVM", "SaveSales");
                }
            }
        }
コード例 #2
0
        private async void MedewerkerLoggen()
        {
            RegisterEmployee re = new RegisterEmployee()
            {
                RegisterID = int.Parse(Properties.Settings.Default.RegisterID), EmployeeID = ApplicationVM.ActiveEmployee.ID, From = ApplicationVM.From, Until = DateTime.Now
            };
            string input = JsonConvert.SerializeObject(re);

            using (HttpClient client = new HttpClient())
            {
                client.SetBearerToken(ApplicationVM.Token.AccessToken);
                HttpResponseMessage response = await client.PostAsync("http://localhost:3655/api/register/", new StringContent(input, Encoding.UTF8, "application/json"));

                if (response.IsSuccessStatusCode)
                {
                    ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM;
                    appvm.ChangePage(new LoginVM());
                }
            }
        }
コード例 #3
0
        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();

                if (json != "null")
                {
                    ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM;
                    ApplicationVM.ActiveCustomer = JsonConvert.DeserializeObject <Customer>(json);

                    appvm.ChangePage(new MainscreenVM());
                }
                else
                {
                    Error = "Gelieve een geregistreerde klanten ID in de reader te plaatsen";
                    CreateErrorlog(Error, "TussenpaginaVM", "ControleerGebruiker");
                }
            }
        }
コード例 #4
0
        private async void ControleerGebruiker(Employee e)
        {
            using (HttpClient client = new HttpClient())
            {
                client.SetBearerToken(ApplicationVM.Token.AccessToken);
                HttpResponseMessage response = await client.GetAsync("http://localhost:3655/Api/Employee/?nummer=" + e.RijksregisterNummer);

                string json = await response.Content.ReadAsStringAsync();

                if (json != "null")
                {
                    ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM;
                    ApplicationVM.ActiveEmployee = JsonConvert.DeserializeObject <Employee>(json);
                    ApplicationVM.From           = DateTime.Now;
                    appvm.ChangePage(new TussenpaginaVM());
                }
                else
                {
                    Error = "De gebruiker is niet gevonden.";
                    CreateErrorlog(Error, "LoginVM", "ControleerGebruiker");
                }
            }
        }