BotUser registriert und eingeloggt
Methoden zum Bot User registrieren und einloggen hinzugefügt aber auskommentiert, weil dies nur zu Debug bzw. Test gründen benutzt wurde
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
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
|
||||
{
|
||||
@@ -15,5 +20,29 @@ namespace bib_talk.Business
|
||||
{
|
||||
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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,8 @@
|
||||
using bib_talk.Repository;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace bib_talk.Business
|
||||
{
|
||||
@@ -15,5 +19,26 @@ namespace bib_talk.Business
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user