bib_Talk_Chatprogramm/bibtalk/bib-talk/Business/LoginManager.cs

53 lines
1.5 KiB
C#
Raw Normal View History

using bib_talk.Repository;
using Newtonsoft.Json;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace bib_talk.Business
{
public class LoginManager
{
private LoginDatabase loginDatabase; // LoginDatabase Objekt initialisieren
// Konstruktor für den LoginManager
public LoginManager(Login loginWindow)
{
loginDatabase = new LoginDatabase(loginWindow); // LoginDatabase Objekt deklarieren
}
// Methode zum User einloggen via LoginDatabase
public async void Login()
{
await loginDatabase.LoginServer();
}
// 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);
// 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<dynamic>(responseContent);
// }
// else
// {
// var responseContent = await response.Content.ReadAsStringAsync();
// MessageBox.Show($"Login failed: {responseContent}");
// }
// }
//}
}
}