Einstellungsbutton Update

Macht es möglich einen Delete Request an den Server zu senden um den Chat zu löschen
This commit is contained in:
DaddyPig
2024-08-30 10:35:09 +02:00
parent 4edc2f2188
commit c390dfe5e3
4 changed files with 43 additions and 9 deletions

View File

@@ -86,6 +86,33 @@ namespace bib_talk.Repository
}
}
}
public async void ClearMessages()
{
using (var client = new HttpClient())
{
try
{
// Sending a DELETE request to the clear messages endpoint
var response = await client.DeleteAsync("http://daddypig.dns.navy:5114/api/messages/clear");
if (response.IsSuccessStatusCode)
{
// Log success message or take any other action as needed
MessageBox.Show("Alle Nachrichten wurden gelöscht");
}
else
{
// Log failure message with the status code
MessageBox.Show($"Fehler beim Löschen der Nachrichten. Status code: {response.StatusCode}");
}
}
catch (Exception ex)
{
// Handle any exceptions that occur during the request
Console.WriteLine($"Ein Fehler ist aufgetreten: {ex.Message}");
}
}
}
// Methode zum Ausloggen des Users via Datenbank
public async void LogoutUser()