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:
parent
4edc2f2188
commit
c390dfe5e3
@ -39,8 +39,14 @@ namespace bib_talk.Business
|
||||
mwDatabase.LogoutUser();
|
||||
}
|
||||
|
||||
// Methode zum Hochladen eines Profilbildes via Datenbankmanager
|
||||
public async Task UploadProfileImage(string filePath)
|
||||
// Methode zum Löschen des Gesamten Chats
|
||||
public void DeleteMessages()
|
||||
{
|
||||
mwDatabase.ClearMessages();
|
||||
}
|
||||
|
||||
// Methode zum Hochladen eines Profilbildes via Datenbankmanager
|
||||
public async Task UploadProfileImage(string filePath)
|
||||
{
|
||||
await mwDatabase.UploadProfileImage(filePath);
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -99,7 +99,7 @@
|
||||
</ContextMenu>
|
||||
</Button.ContextMenu>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid Margin="76,17,339,176">
|
||||
|
||||
<Rectangle Stroke="#FF282828" Fill="#FF282828"/>
|
||||
|
@ -89,9 +89,9 @@ namespace bib_talk
|
||||
}
|
||||
}
|
||||
|
||||
#region Ohne Funktion
|
||||
// Chat Settings Logik
|
||||
private void MenuButton_Click(object sender, RoutedEventArgs e)
|
||||
#region Ohne Funktion (Fast)
|
||||
// Chat Settings Logik
|
||||
private void MenuButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Öffnen Sie das Kontextmenü, wenn Sie auf den Drei-Punkte-Button klicken
|
||||
contextMenu.IsOpen = true;
|
||||
@ -104,13 +104,14 @@ namespace bib_talk
|
||||
|
||||
private void clearChatButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Logik zum Löschen eines Chats
|
||||
//Rufe die Methode zum Löschen des Chats auf
|
||||
mwManager.DeleteMessages();
|
||||
}
|
||||
|
||||
private void helpButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Logik zum Entfernen eines Freundes
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user