using bib_talk.Repository; using Newtonsoft.Json; using System.Net.Http; using System.Text; using System.Windows; namespace bib_talk.Business { public class RegisterManager { private RegisterDatabase registerDatabase; public RegisterManager(RegisterWindow registerWindow) { registerDatabase = new RegisterDatabase(registerWindow); } public async void RegisterServer() { await registerDatabase.RegisterServer(); } public async void RegisterBots(string username, string password, string email, string birthday) { 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); } } } } }