2024-07-03 15:58:51 +02:00
|
|
|
|
using bib_talk.Repository;
|
2024-08-28 12:01:03 +02:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows;
|
2024-07-03 15:58:51 +02:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
2024-08-28 12:01:03 +02:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-03 15:58:51 +02:00
|
|
|
|
}
|
|
|
|
|
}
|