Errorhandling Token problems

This commit is contained in:
2024-09-11 14:29:21 +02:00
parent 6cf55aa258
commit 4f91c63400
4 changed files with 113 additions and 62 deletions

View File

@@ -71,7 +71,9 @@ namespace Jugenddienst_Stunden.ViewModels {
GetDay = dateToday.Day;
OnPropertyChanged();
_ = LoadData(); // Use discard operator to explicitly ignore the returned Task
RefreshProperties();
//RefreshProperties();
OnPropertyChanged(nameof(TimeDay));
OnPropertyChanged(nameof(ShowDay));
}
}
}
@@ -144,15 +146,29 @@ namespace Jugenddienst_Stunden.ViewModels {
public async Task LoadData() {
try {
_hour = await Models.Stunde.LoadData();
if (_hour.zeit_total_daily_api != null) {
TimeDay = _hour.zeit_total_daily_api.Where(static p => p.Day == GetDay).ToList() ?? new List<TimeDay> { new TimeDay { Day = GetDay, Hours = 0 } };
RefreshProperties();
}
} catch (Exception e) {
AlertEvent?.Invoke(this, e.Message);
}
//Models.Hours Hours = new Models.Hours();
//Title = _hour.operator_api.name + " " + _hour.operator_api.surname;
if (_hour != null) {
TimeDay = _hour.zeit_total_daily_api.Where(p => p.Day == GetDay).ToList();
RefreshProperties();
}
//if (_hour.zeit_total_daily_api != null) {
// try {
// TimeDay = _hour.zeit_total_daily_api.Where(static p => p.Day == GetDay).ToList() ?? new List<TimeDay> { new TimeDay { Day = GetDay, Hours = 0 } };
// RefreshProperties();
// } catch (Exception e) {
// AlertEvent?.Invoke(this, e.Message);
// }
//} else {
// await App.Current.MainPage.DisplayAlert("Fehler",
// "zeit_total_daily_api ist leer",
// "OK");
//}
}
private void RefreshProperties() {