From 068ba16156b32e402b16ec0aebfb32fe4e3936e2 Mon Sep 17 00:00:00 2001 From: BlackViron Date: Mon, 1 Jul 2024 16:21:03 +0200 Subject: [PATCH] 3 Schichten Model 3 Schichten Model umgesetzt --- bibtalk/bib-talk/App.xaml | 2 +- bibtalk/bib-talk/Business/readme.txt | 2 + .../bib-talk/{ => Icons}/Logo_bib-Talk.png | Bin bibtalk/bib-talk/{ => Icons}/PICA.jpg | Bin bibtalk/bib-talk/{ => Icons}/logo.png | Bin bibtalk/bib-talk/MainWindow.xaml.cs | 238 ------------------ bibtalk/bib-talk/Repository/LoginDatabase.cs | 51 ++++ .../bib-talk/Repository/MainWindowDatabase.cs | 96 +++++++ .../bib-talk/Repository/RegisterDatabase.cs | 47 ++++ bibtalk/bib-talk/{ => UI}/Login.xaml | 0 bibtalk/bib-talk/{ => UI}/Login.xaml.cs | 41 +-- bibtalk/bib-talk/{ => UI}/MainWindow.xaml | 0 bibtalk/bib-talk/UI/MainWindow.xaml.cs | 157 ++++++++++++ bibtalk/bib-talk/{ => UI}/RegisterWindow.xaml | 0 .../bib-talk/{ => UI}/RegisterWindow.xaml.cs | 32 +-- bibtalk/bib-talk/bib-talk.csproj | 10 +- 16 files changed, 372 insertions(+), 304 deletions(-) create mode 100644 bibtalk/bib-talk/Business/readme.txt rename bibtalk/bib-talk/{ => Icons}/Logo_bib-Talk.png (100%) rename bibtalk/bib-talk/{ => Icons}/PICA.jpg (100%) rename bibtalk/bib-talk/{ => Icons}/logo.png (100%) delete mode 100644 bibtalk/bib-talk/MainWindow.xaml.cs create mode 100644 bibtalk/bib-talk/Repository/LoginDatabase.cs create mode 100644 bibtalk/bib-talk/Repository/MainWindowDatabase.cs create mode 100644 bibtalk/bib-talk/Repository/RegisterDatabase.cs rename bibtalk/bib-talk/{ => UI}/Login.xaml (100%) rename bibtalk/bib-talk/{ => UI}/Login.xaml.cs (58%) rename bibtalk/bib-talk/{ => UI}/MainWindow.xaml (100%) create mode 100644 bibtalk/bib-talk/UI/MainWindow.xaml.cs rename bibtalk/bib-talk/{ => UI}/RegisterWindow.xaml (100%) rename bibtalk/bib-talk/{ => UI}/RegisterWindow.xaml.cs (77%) diff --git a/bibtalk/bib-talk/App.xaml b/bibtalk/bib-talk/App.xaml index 0d752b2..a147578 100644 --- a/bibtalk/bib-talk/App.xaml +++ b/bibtalk/bib-talk/App.xaml @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:bib_talk" - StartupUri="Login.xaml"> + StartupUri="UI/Login.xaml"> diff --git a/bibtalk/bib-talk/Business/readme.txt b/bibtalk/bib-talk/Business/readme.txt new file mode 100644 index 0000000..ac5e280 --- /dev/null +++ b/bibtalk/bib-talk/Business/readme.txt @@ -0,0 +1,2 @@ +Alle Business Klassen sind die [name].xaml.cs Dateien. +Diese sind NICHT in diesem Ordner, weil wir sie von der [name].xaml Datei nicht trennen können. \ No newline at end of file diff --git a/bibtalk/bib-talk/Logo_bib-Talk.png b/bibtalk/bib-talk/Icons/Logo_bib-Talk.png similarity index 100% rename from bibtalk/bib-talk/Logo_bib-Talk.png rename to bibtalk/bib-talk/Icons/Logo_bib-Talk.png diff --git a/bibtalk/bib-talk/PICA.jpg b/bibtalk/bib-talk/Icons/PICA.jpg similarity index 100% rename from bibtalk/bib-talk/PICA.jpg rename to bibtalk/bib-talk/Icons/PICA.jpg diff --git a/bibtalk/bib-talk/logo.png b/bibtalk/bib-talk/Icons/logo.png similarity index 100% rename from bibtalk/bib-talk/logo.png rename to bibtalk/bib-talk/Icons/logo.png diff --git a/bibtalk/bib-talk/MainWindow.xaml.cs b/bibtalk/bib-talk/MainWindow.xaml.cs deleted file mode 100644 index 8d6fcf4..0000000 --- a/bibtalk/bib-talk/MainWindow.xaml.cs +++ /dev/null @@ -1,238 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Globalization; -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.Input; -using System.Windows.Media; -using System.Windows.Threading; - -namespace bib_talk -{ - public partial class MainWindow : Window - { - private DispatcherTimer _timer; - public string loggedinUser; - private bool isFirstLoad = true; - - public MainWindow() - { - InitializeComponent(); - InitializeTimer(); - LoadData(); - } - - public MainWindow(string user) - { - loggedinUser = user; - InitializeComponent(); - InitializeTimer(); - LoadData(); - LoadMessages(); - } - - private void InitializeTimer() - { - _timer = new DispatcherTimer - { - Interval = TimeSpan.FromSeconds(2) - }; - _timer.Tick += (sender, e) => { LoadMessages(); LoadOnlineUsers(); }; - _timer.Start(); - } - public void LoadData() - { - loggedinuser.Text = "Logged in as: " + loggedinUser; - } - - private void CloseButton_Click(object sender, RoutedEventArgs e) - { - LogoutUser(); - this.Close(); - } - - private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) - { - if (e.ButtonState == MouseButtonState.Pressed) - { - DragMove(); - } - } - - private async void LoadMessages() - { - using (var client = new HttpClient()) - { - var response = await client.GetAsync("http://daddypig.dns.navy:5114/api/messages/get"); - if (response.IsSuccessStatusCode) - { - var responseContent = await response.Content.ReadAsStringAsync(); - var messages = JsonConvert.DeserializeObject>(responseContent); - chatlistbox.ItemsSource = messages; - if (chatlistbox.Items.Count > 0) - { - var lastItem = chatlistbox.Items[chatlistbox.Items.Count - 1]; - chatlistbox.ScrollIntoView(lastItem); - } - } - } - } - private async void LogoutUser() - { - using (var client = new HttpClient()) - { - var logoutData = new { Username = loggedinUser, Password = "", Email = "", Birthday = "", IsOnline = "" }; - var json = JsonConvert.SerializeObject(logoutData); - var content = new StringContent(json, Encoding.UTF8, "application/json"); - - var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/users/logout", content); - - var responseContent = await response.Content.ReadAsStringAsync(); - - this.Close(); - } - } - private async void LoadOnlineUsers() - { - using (var client = new HttpClient()) - { - var response = await client.GetAsync("http://daddypig.dns.navy:5114/api/users/online-users"); - if (response.IsSuccessStatusCode) - { - var responseContent = await response.Content.ReadAsStringAsync(); - var onlineUsers = JsonConvert.DeserializeObject>(responseContent); - onlineUsersListBox.ItemsSource = onlineUsers; - } - } - } - - private async void messageBOX_KeyDown(object sender, KeyEventArgs e) - { - if (e.Key == Key.Enter) - { - if (!string.IsNullOrEmpty(messageBOX.Text)) - { - var message = new MessageDto - { - Username = loggedinUser, - Message = messageBOX.Text, - Timestamp = DateTime.Now, - }; - - using (var client = new HttpClient()) - { - var json = JsonConvert.SerializeObject(message); - var content = new StringContent(json, Encoding.UTF8, "application/json"); - var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/messages/send", content); - - if (response.IsSuccessStatusCode) - { - messageBOX.Clear(); - LoadMessages(); // Reload messages after sending - } - } - } - } - } - private async void send_Click(object sender, RoutedEventArgs e) - { - if (!string.IsNullOrEmpty(messageBOX.Text)) - { - var message = new MessageDto - { - Username = loggedinUser, - Message = messageBOX.Text, - Timestamp = DateTime.Now, - }; - - using (var client = new HttpClient()) - { - var json = JsonConvert.SerializeObject(message); - var content = new StringContent(json, Encoding.UTF8, "application/json"); - var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/messages/send", content); - - if (response.IsSuccessStatusCode) - { - messageBOX.Clear(); - LoadMessages(); // Reload messages after sending - } - } - } - } - - public class Message - { - public int Id { get; set; } - public string Username { get; set; } - public string Text { get; set; } - public DateTime Timestamp { get; set; } - } - - public class MessageDto - { - public string Username { get; set; } - public string Message { get; set; } - public DateTime Timestamp { get; set; } - } - public class User - { - public int Id { get; set; } - public string Username { get; set; } - public string Password { get; set; } - public string Email { get; set; } - public string Birthday { get; set; } - public string IsOnline { get; set; } - } - - private void ChatFenster_Click(object sender, RoutedEventArgs e) - { - if (popup.IsOpen = true) - { - popup.Focus(); - } - else - { - popup.IsOpen = true; - } - - } - private void Button1_Click(object sender, RoutedEventArgs e) - { - MessageBox.Show("Button 1 wurde geklickt!"); - ClosePopup(); - } - - private void Button2_Click(object sender, RoutedEventArgs e) - { - MessageBox.Show("Button 2 wurde geklickt!"); - ClosePopup(); - } - - private void Button3_Click(object sender, RoutedEventArgs e) - { - MessageBox.Show("Button 3 wurde geklickt!"); - ClosePopup(); - } - - private void Popup_LostFocus(object sender, RoutedEventArgs e) - { - - ClosePopup(); - } - - private void ClosePopup() - { - popup.IsOpen = false; - } - - private void onlineUsersListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - - } - } -} diff --git a/bibtalk/bib-talk/Repository/LoginDatabase.cs b/bibtalk/bib-talk/Repository/LoginDatabase.cs new file mode 100644 index 0000000..bc79991 --- /dev/null +++ b/bibtalk/bib-talk/Repository/LoginDatabase.cs @@ -0,0 +1,51 @@ +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.Controls; +using System.Windows; + +namespace bib_talk.Repository +{ + public class LoginDatabase + { + Login loginWindow; + + public LoginDatabase(Login loginWindow) + { + this.loginWindow = loginWindow; + } + + public async Task LoginServer() + { + string username = loginWindow.usernbox.Text; + string password = loginWindow.passwordbox.Password; + var loginData = new { Username = username, Password = password, Email = "", Birthday = "", IsOnline = "" }; + string json = JsonConvert.SerializeObject(loginData); + + 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/login", content); + + if (response.IsSuccessStatusCode) + { + var responseContent = await response.Content.ReadAsStringAsync(); + var responseData = JsonConvert.DeserializeObject(responseContent); + string loggedInUsername = responseData.username; + MainWindow mainWindow = new MainWindow(loggedInUsername); + mainWindow.Show(); + loginWindow.Close(); + } + else + { + var responseContent = await response.Content.ReadAsStringAsync(); + MessageBox.Show($"Login failed: {responseContent}"); + } + } + } + } +} diff --git a/bibtalk/bib-talk/Repository/MainWindowDatabase.cs b/bibtalk/bib-talk/Repository/MainWindowDatabase.cs new file mode 100644 index 0000000..c4dc2ec --- /dev/null +++ b/bibtalk/bib-talk/Repository/MainWindowDatabase.cs @@ -0,0 +1,96 @@ +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; + +namespace bib_talk.Repository +{ + public class MainWindowDatabase + { + MainWindow mainWindow; + + public MainWindowDatabase(MainWindow mainWindow) + { + this.mainWindow = mainWindow; + } + + public async void SendMessage() + { + if (!string.IsNullOrEmpty(mainWindow.messageBOX.Text)) + { + var message = new MessageDto + { + Username = mainWindow.loggedinUser, + Message = mainWindow.messageBOX.Text, + Timestamp = DateTime.Now, + }; + + using (var client = new HttpClient()) + { + var json = JsonConvert.SerializeObject(message); + var content = new StringContent(json, Encoding.UTF8, "application/json"); + var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/messages/send", content); + + if (response.IsSuccessStatusCode) + { + mainWindow.messageBOX.Clear(); + LoadMessages(); // Reload messages after sending + } + } + } + } + + public async void LoadMessages() + { + using (var client = new HttpClient()) + { + var response = await client.GetAsync("http://daddypig.dns.navy:5114/api/messages/get"); + if (response.IsSuccessStatusCode) + { + var responseContent = await response.Content.ReadAsStringAsync(); + var messages = JsonConvert.DeserializeObject>(responseContent); + mainWindow.chatlistbox.ItemsSource = messages; + if (mainWindow.chatlistbox.Items.Count > 0) + { + var lastItem = mainWindow.chatlistbox.Items[mainWindow.chatlistbox.Items.Count - 1]; + mainWindow.chatlistbox.ScrollIntoView(lastItem); + } + } + } + } + + public async void LoadOnlineUsers() + { + using (var client = new HttpClient()) + { + var response = await client.GetAsync("http://daddypig.dns.navy:5114/api/users/online-users"); + if (response.IsSuccessStatusCode) + { + var responseContent = await response.Content.ReadAsStringAsync(); + var onlineUsers = JsonConvert.DeserializeObject>(responseContent); + mainWindow.onlineUsersListBox.ItemsSource = onlineUsers; + } + } + } + + public async void LogoutUser() + { + using (var client = new HttpClient()) + { + var logoutData = new { Username = mainWindow.loggedinUser, Password = "", Email = "", Birthday = "", IsOnline = "" }; + var json = JsonConvert.SerializeObject(logoutData); + var content = new StringContent(json, Encoding.UTF8, "application/json"); + + var response = await client.PostAsync("http://daddypig.dns.navy:5114/api/users/logout", content); + + var responseContent = await response.Content.ReadAsStringAsync(); + + mainWindow.Close(); + } + } + } +} diff --git a/bibtalk/bib-talk/Repository/RegisterDatabase.cs b/bibtalk/bib-talk/Repository/RegisterDatabase.cs new file mode 100644 index 0000000..e8ea303 --- /dev/null +++ b/bibtalk/bib-talk/Repository/RegisterDatabase.cs @@ -0,0 +1,47 @@ +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.Controls; +using System.Windows; + +namespace bib_talk.Repository +{ + public class RegisterDatabase + { + RegisterWindow registerWindow; + + public RegisterDatabase(RegisterWindow registerWindow) + { + this.registerWindow = registerWindow; + } + + public async Task RegisterServer() + { + string username = registerWindow.usernbox.Text; + string password = registerWindow.passwordbox.Password; + string email = registerWindow.emailbox.Text; + string birthday = $"{registerWindow.bday1.Text}.{registerWindow.bday2.Text}.{registerWindow.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("Registrierung erfolgreich."); + } + else + { + MessageBox.Show("Registrierung fehlgeschlagen. " + response); + } + } + } + } +} diff --git a/bibtalk/bib-talk/Login.xaml b/bibtalk/bib-talk/UI/Login.xaml similarity index 100% rename from bibtalk/bib-talk/Login.xaml rename to bibtalk/bib-talk/UI/Login.xaml diff --git a/bibtalk/bib-talk/Login.xaml.cs b/bibtalk/bib-talk/UI/Login.xaml.cs similarity index 58% rename from bibtalk/bib-talk/Login.xaml.cs rename to bibtalk/bib-talk/UI/Login.xaml.cs index 8f6feea..a734283 100644 --- a/bibtalk/bib-talk/Login.xaml.cs +++ b/bibtalk/bib-talk/UI/Login.xaml.cs @@ -5,17 +5,23 @@ using System.Threading.Tasks; using System.Windows.Input; using System.Windows.Media; using System.Windows; +using bib_talk.Repository; namespace bib_talk { public partial class Login : Window { + LoginDatabase loginDatabase; + + // Field to store logged in user public static string loggedInUser; public Login() { InitializeComponent(); + + loginDatabase = new LoginDatabase(this); } private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) @@ -38,11 +44,12 @@ namespace bib_talk this.Close(); } - private void WeiterButton_Click(object sender, RoutedEventArgs e) + private async void WeiterButton_Click(object sender, RoutedEventArgs e) { if (usernbox.Text != "" && passwordbox.Password != "") { - LoginServer(); + + await loginDatabase.LoginServer(); } } @@ -69,35 +76,5 @@ namespace bib_talk register.Show(); this.Close(); } - - public async Task LoginServer() - { - string username = usernbox.Text; - string password = passwordbox.Password; - var loginData = new { Username = username, Password = password, Email = "", Birthday = "", IsOnline = ""}; - string json = JsonConvert.SerializeObject(loginData); - - 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/login", content); - - if (response.IsSuccessStatusCode) - { - var responseContent = await response.Content.ReadAsStringAsync(); - var responseData = JsonConvert.DeserializeObject(responseContent); - string loggedInUsername = responseData.username; - MainWindow mainWindow = new MainWindow(loggedInUsername); - mainWindow.Show(); - this.Close(); - } - else - { - var responseContent = await response.Content.ReadAsStringAsync(); - MessageBox.Show($"Login failed: {responseContent}"); - } - } - } - } } diff --git a/bibtalk/bib-talk/MainWindow.xaml b/bibtalk/bib-talk/UI/MainWindow.xaml similarity index 100% rename from bibtalk/bib-talk/MainWindow.xaml rename to bibtalk/bib-talk/UI/MainWindow.xaml diff --git a/bibtalk/bib-talk/UI/MainWindow.xaml.cs b/bibtalk/bib-talk/UI/MainWindow.xaml.cs new file mode 100644 index 0000000..82eb8f3 --- /dev/null +++ b/bibtalk/bib-talk/UI/MainWindow.xaml.cs @@ -0,0 +1,157 @@ +using bib_talk.Repository; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Globalization; +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.Input; +using System.Windows.Media; +using System.Windows.Threading; + +namespace bib_talk +{ + public partial class MainWindow : Window + { + MainWindowDatabase database; + + private DispatcherTimer _timer; + public string loggedinUser; + private bool isFirstLoad = true; + + public MainWindow() + { + InitializeComponent(); + InitializeTimer(); + LoadData(); + + database = new MainWindowDatabase(this); + } + + public MainWindow(string user) + { + loggedinUser = user; + InitializeComponent(); + InitializeTimer(); + LoadData(); + + database = new MainWindowDatabase(this); + + database.LoadMessages(); + } + + private void InitializeTimer() + { + _timer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(2) + }; + _timer.Tick += (sender, e) => { database.LoadMessages(); database.LoadOnlineUsers(); }; + _timer.Start(); + } + public void LoadData() + { + loggedinuser.Text = "Logged in as: " + loggedinUser; + } + + private void CloseButton_Click(object sender, RoutedEventArgs e) + { + database.LogoutUser(); + this.Close(); + } + + private void DraggableArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + if (e.ButtonState == MouseButtonState.Pressed) + { + DragMove(); + } + } + + private async void messageBOX_KeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Enter) + { + database.SendMessage(); + } + } + + private async void send_Click(object sender, RoutedEventArgs e) + { + database.SendMessage(); + } + + private void ChatFenster_Click(object sender, RoutedEventArgs e) + { + if (popup.IsOpen = true) + { + popup.Focus(); + } + else + { + popup.IsOpen = true; + } + + } + private void Button1_Click(object sender, RoutedEventArgs e) + { + MessageBox.Show("Button 1 wurde geklickt!"); + ClosePopup(); + } + + private void Button2_Click(object sender, RoutedEventArgs e) + { + MessageBox.Show("Button 2 wurde geklickt!"); + ClosePopup(); + } + + private void Button3_Click(object sender, RoutedEventArgs e) + { + MessageBox.Show("Button 3 wurde geklickt!"); + ClosePopup(); + } + + private void Popup_LostFocus(object sender, RoutedEventArgs e) + { + + ClosePopup(); + } + + private void ClosePopup() + { + popup.IsOpen = false; + } + + private void onlineUsersListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + + } + } + + public class Message + { + public int Id { get; set; } + public string Username { get; set; } + public string Text { get; set; } + public DateTime Timestamp { get; set; } + } + public class MessageDto + { + public string Username { get; set; } + public string Message { get; set; } + public DateTime Timestamp { get; set; } + } + public class User + { + public int Id { get; set; } + public string Username { get; set; } + public string Password { get; set; } + public string Email { get; set; } + public string Birthday { get; set; } + public string IsOnline { get; set; } + } +} diff --git a/bibtalk/bib-talk/RegisterWindow.xaml b/bibtalk/bib-talk/UI/RegisterWindow.xaml similarity index 100% rename from bibtalk/bib-talk/RegisterWindow.xaml rename to bibtalk/bib-talk/UI/RegisterWindow.xaml diff --git a/bibtalk/bib-talk/RegisterWindow.xaml.cs b/bibtalk/bib-talk/UI/RegisterWindow.xaml.cs similarity index 77% rename from bibtalk/bib-talk/RegisterWindow.xaml.cs rename to bibtalk/bib-talk/UI/RegisterWindow.xaml.cs index 1cff4c6..5781205 100644 --- a/bibtalk/bib-talk/RegisterWindow.xaml.cs +++ b/bibtalk/bib-talk/UI/RegisterWindow.xaml.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using bib_talk.Repository; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Diagnostics; @@ -52,13 +53,15 @@ namespace bib_talk this.Close(); } - private void WeiterButton_Click(object sender, RoutedEventArgs e) + private async void WeiterButton_Click(object sender, RoutedEventArgs e) { if (checkboxAGB.IsChecked == true) { if (ValidateRegistration()) { - RegisterServer(); + RegisterDatabase registerDatabase = new RegisterDatabase(this); + + await registerDatabase.RegisterServer(); Login login = new Login(); login.Show(); this.Close(); @@ -125,29 +128,6 @@ namespace bib_talk return true; } - 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("Registrierung erfolgreich."); - } - else - { - MessageBox.Show("Registrierung fehlgeschlagen. " + response); - } - } - } } } diff --git a/bibtalk/bib-talk/bib-talk.csproj b/bibtalk/bib-talk/bib-talk.csproj index 485dad0..5370b4f 100644 --- a/bibtalk/bib-talk/bib-talk.csproj +++ b/bibtalk/bib-talk/bib-talk.csproj @@ -19,13 +19,9 @@ - - - - - - - + + +