d9976ff520
Methoden zum Bot User registrieren und einloggen hinzugefügt aber auskommentiert, weil dies nur zu Debug bzw. Test gründen benutzt wurde
49 lines
1.2 KiB
C#
49 lines
1.2 KiB
C#
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;
|
|
|
|
public LoginManager(Login loginWindow)
|
|
{
|
|
loginDatabase = new LoginDatabase(loginWindow);
|
|
}
|
|
|
|
public async void Login()
|
|
{
|
|
await loginDatabase.LoginServer();
|
|
}
|
|
|
|
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}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|