27 lines
857 B
C#
27 lines
857 B
C#
using System.Net.Http;
|
|
using System.Text;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
|
|
|
|
//jakob
|
|
namespace Pen_Paper_Main
|
|
{
|
|
public partial class CharakterNeu : Window
|
|
{
|
|
public CharakterNeu() { InitializeComponent(); }
|
|
|
|
private async void Save_Click(object s, RoutedEventArgs e)
|
|
{
|
|
var payload = new { username = TxtUser.Text, name = TxtChar.Text };
|
|
using var http = new HttpClient();
|
|
var resp = await http.PostAsync("http://localhost/api/characters.php?action=create",
|
|
new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json"));
|
|
var body = await resp.Content.ReadAsStringAsync();
|
|
MessageBox.Show(body);
|
|
DialogResult = true; Close();
|
|
}
|
|
}
|
|
}
|