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.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
2024-07-03 15:58:51 +02:00
|
|
|
|
|
|
|
|
|
namespace bib_talk.Business
|
|
|
|
|
{
|
|
|
|
|
public class LoginManager
|
|
|
|
|
{
|
2024-08-28 13:53:39 +02:00
|
|
|
|
private LoginDatabase loginDatabase; // LoginDatabase Objekt initialisieren
|
2024-07-03 15:58:51 +02:00
|
|
|
|
|
2024-08-28 13:53:39 +02:00
|
|
|
|
// Konstruktor für den LoginManager
|
2024-07-03 15:58:51 +02:00
|
|
|
|
public LoginManager(Login loginWindow)
|
|
|
|
|
{
|
2024-08-28 13:53:39 +02:00
|
|
|
|
loginDatabase = new LoginDatabase(loginWindow); // LoginDatabase Objekt deklarieren
|
2024-07-03 15:58:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-28 13:53:39 +02:00
|
|
|
|
// Methode zum User einloggen via LoginDatabase
|
2024-07-03 15:58:51 +02:00
|
|
|
|
public async void Login()
|
|
|
|
|
{
|
|
|
|
|
await loginDatabase.LoginServer();
|
|
|
|
|
}
|
2024-08-28 12:01:03 +02:00
|
|
|
|
|
2024-08-28 13:53:39 +02:00
|
|
|
|
// DEBUG METHODE
|
|
|
|
|
// Methode um Bots einzuloggen
|
|
|
|
|
//public async Task LoginBots(string username, string password)
|
|
|
|
|
//{
|
|
|
|
|
// var loginData = new { Username = username, Password = password, Email = "", Birthday = "", IsOnline = "" };
|
|
|
|
|
// string json = JsonConvert.SerializeObject(loginData);
|
2024-08-28 12:01:03 +02:00
|
|
|
|
|
2024-08-28 13:53:39 +02:00
|
|
|
|
// 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);
|
2024-08-28 12:01:03 +02:00
|
|
|
|
|
2024-08-28 13:53:39 +02:00
|
|
|
|
// if (response.IsSuccessStatusCode)
|
|
|
|
|
// {
|
|
|
|
|
// var responseContent = await response.Content.ReadAsStringAsync();
|
|
|
|
|
// var responseData = JsonConvert.DeserializeObject<dynamic>(responseContent);
|
2024-08-28 12:01:03 +02:00
|
|
|
|
|
2024-08-28 13:53:39 +02:00
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// var responseContent = await response.Content.ReadAsStringAsync();
|
|
|
|
|
// MessageBox.Show($"Login failed: {responseContent}");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2024-07-03 15:58:51 +02:00
|
|
|
|
}
|
|
|
|
|
}
|