Save / Update / Delete Entrys

This commit is contained in:
2024-09-26 11:31:02 +02:00
parent 8f7e4bb09e
commit df9e999a34
9 changed files with 133 additions and 44 deletions

View File

@@ -70,6 +70,24 @@ namespace Jugenddienst_Stunden.Models {
//}
}
public static async Task DeleteItemAsync(string url, string token) {
//using (HttpClient client = new HttpClient() { Timeout = TimeSpan.FromSeconds(15) }) {
try {
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
HttpResponseMessage response = await client.DeleteAsync(url);
if (response.IsSuccessStatusCode)
Debug.WriteLine(@"\tTodoItem successfully deleted.");
} catch (Exception ex) {
Debug.WriteLine(@"\tERROR {0}", ex.Message);
}
//}
}
}
}