using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Net.Http; using Newtonsoft.Json; namespace bib_talk { public partial class RegisterWindow : Window { public RegisterWindow() { InitializeComponent(); } private void CloseButton_Click(object sender, RoutedEventArgs e) { this.Close(); } private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (e.ButtonState == MouseButtonState.Pressed) { DragMove(); } } private void Login_Click(object sender, RoutedEventArgs e) { Login login= new Login(); login.Show(); this.Close(); } private void WeiterButton_Click(object sender, RoutedEventArgs e) { if (checkboxAGB.IsChecked == true) { RegisterServer(); } } private void CheckBox_Checked(object sender, RoutedEventArgs e) { SolidColorBrush customBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF6332A0")); weiterbutton.Foreground = Brushes.White; weiterbutton.Background = customBrush; } private void CheckBox_Unchecked(object sender, RoutedEventArgs e) { SolidColorBrush customBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF323134")); weiterbutton.Foreground = Brushes.Gray; weiterbutton.Background= customBrush; } public async Task RegisterServer() { string username = usernbox.Text; string password = passwordbox.Password; string email = emailbox.Text; string birthday = bday1.Text+"."+bday2.Text+"."+bday3.Text; var newUser = new { Username = username, Password = password, Email = email, Birthday = birthday, IsOnline = ""}; string json = JsonConvert.SerializeObject(newUser); using (var client = new HttpClient()) { var content = new StringContent(json, Encoding.UTF8, "application/json"); var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/users/register", content); if (response.IsSuccessStatusCode) { MessageBox.Show("Registration Succesful"); } else { MessageBox.Show("Registration failed."+ response); } } } } }