private void RegistrationAccount(object sender, RoutedEventArgs e) { if (txtPassword.Text == "" || txtUsername.Text == "") { MessageBox.Show("Please fill in the empty fields!"); } else { try { HttpWebRequest request = WebRequest.CreateHttp($"{ Api.Url }/boss/addBoss"); request.Method = "POST"; request.ContentType = "application/json"; using (StreamWriter stream = new StreamWriter(request.GetRequestStream())) { string json = JsonConvert.SerializeObject(new BossModel() { Username = txtUsername.Text, Password = txtPassword.Text }); stream.Write(json); } WebResponse response = request.GetResponse(); MessageBox.Show(response.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); } LoginBoss logIn = new LoginBoss(); logIn.Show(); this.Close(); } }
private void PreviewPage(object sender, RoutedEventArgs e) { LoginBoss logIn = new LoginBoss(); logIn.Show(); this.Close(); }