Api Changes

This commit is contained in:
2024-09-13 19:24:41 +02:00
parent 644a8e1899
commit d54c71a037
3 changed files with 68 additions and 42 deletions

View File

@@ -84,5 +84,38 @@ namespace Jugenddienst_Stunden.Models
}
public static async Task<Hours> LoadDay(DateTime date) {
Hours hours = new Hours();
if (Connectivity.Current.NetworkAccess == NetworkAccess.None) {
await App.Current.MainPage.DisplayAlert("Keine Internetverbindung",
"Bitte überprüfen Sie Ihre Internetverbindung und versuchen Sie es erneut.",
"OK");
} else {
var tokendata = new TokenData(apiKey);
//string data = await Auth.GetApiDataWithAuthAsync(requestUrl, apiKey);
string data = await Auth.GetApiDataWithAuthAsync(tokendata.url + "?hours&date="+date.ToString("yyyy-MM-dd"), tokendata.apiKey);
if (data == null) {
throw new Exception("Keine Daten erhalten");
}
if (data == "\"Lalala\"") {
throw new Exception("Problem mit Token");
}
hours = JsonConvert.DeserializeObject<Hours>(data);
//Preferences.Default.Set("name", hours.operator_api.name);
//Preferences.Default.Set("surname", hours.operator_api.surname);
}
return hours;
}
}
}