diff --git a/Jugenddienst Stunden/Models/Stunde.cs b/Jugenddienst Stunden/Models/Stunde.cs index 202ebbc..7778956 100644 --- a/Jugenddienst Stunden/Models/Stunde.cs +++ b/Jugenddienst Stunden/Models/Stunde.cs @@ -22,7 +22,7 @@ namespace Jugenddienst_Stunden.Models { //public static string surname = Preferences.Default.Get("surname", "Weger"); //Christine Feichter - public static string apiKey = Preferences.Default.Get("apiKey", "M3xraUdoSktrdGowaUZoaStJbDJLWmIyTFhYeDh8aHR0cDovL2hvdXJzLmRhdW5pLm1pbmUubnU6ODEvYXBwYXBp"); + public static string apiKey = Preferences.Default.Get("apiKey", ""); public static int EmployeeId = Preferences.Default.Get("employeeId", 3); public static string name = Preferences.Default.Get("name", "Vorname"); public static string surname = Preferences.Default.Get("surname", "Nachname"); @@ -34,11 +34,13 @@ namespace Jugenddienst_Stunden.Models { //private static readonly string requestUrl = $"{BaseAddress}/appapi?hours"; //public static string apiKey = "Mnx6amdpUkFCdWMvc0lmZ3dWeXRVSWx3VGRDRDh8aHR0cDovL2hvdXJzLmRhdW5pLm1pbmUubnU6ODEvYXBwYXBp"; //Daniel Pichler - //public static string apiKey = "M3xraUdoSktrdGowaUZoaStJbDJLWmIyTFhYeDh8aHR0cDovL2hvdXJzLmRhdW5pLm1pbmUubnU6ODEvYXBwYXBp"; //Daniel Pichler + //public static string apiKey = "M3xraUdoSktrdGowaUZoaStJbDJLWmIyTFhYeDh8aHR0cDovL2hvdXJzLmRhdW5pLm1pbmUubnU6ODEvYXBwYXBp"; //Le Mair public static async Task LoadData() { - + if (string.IsNullOrEmpty(apiKey)) { + throw new Exception("Kein APIKEY, bitte zuerst Login durchführen"); + } Hours hours = new Hours(); @@ -93,7 +95,9 @@ namespace Jugenddienst_Stunden.Models { } public static async Task> LoadDay(DateTime date) { - + if (string.IsNullOrEmpty(apiKey)) { + throw new Exception("Kein APIKEY, bitte zuerst Login durchführen"); + } List daytimes = new List(); if (Connectivity.Current.NetworkAccess == NetworkAccess.None) { @@ -122,7 +126,6 @@ namespace Jugenddienst_Stunden.Models { return daytimes; } - public static async Task LoadEntry(int id) { var tokendata = new TokenData(apiKey); @@ -136,7 +139,6 @@ namespace Jugenddienst_Stunden.Models { return hours; } - public static Stunde Load(string filename) { filename = System.IO.Path.Combine(FileSystem.AppDataDirectory, filename); diff --git a/Jugenddienst Stunden/ViewModels/StundenViewModel.cs b/Jugenddienst Stunden/ViewModels/StundenViewModel.cs index 360b1d0..6633475 100644 --- a/Jugenddienst Stunden/ViewModels/StundenViewModel.cs +++ b/Jugenddienst Stunden/ViewModels/StundenViewModel.cs @@ -8,6 +8,7 @@ using System.Collections.ObjectModel; using System.ComponentModel; using Jugenddienst_Stunden.Types; using System.Globalization; +using System; namespace Jugenddienst_Stunden.ViewModels { @@ -115,9 +116,10 @@ namespace Jugenddienst_Stunden.ViewModels { public List TimeDay { get; set; } - + public static string apiKey = Preferences.Default.Get("apiKey", ""); public StundenViewModel() { + _hour = new Types.Hours(); LoadDataCommand = new AsyncRelayCommand(LoadData); @@ -129,6 +131,7 @@ namespace Jugenddienst_Stunden.ViewModels { OnPropertyChanged(nameof(DayTimes)); } + private async Task NewEntryAsync() { //Hier muss das Datum übergeben werden //await Shell.Current.GoToAsync(nameof(Views.StundePage)); @@ -158,7 +161,8 @@ namespace Jugenddienst_Stunden.ViewModels { ////TimeDay = _hour.zeit_total_daily_api.Where(static p => p.Day == GetDay.Day).ToList() ?? new List { new TimeDay { Day = GetDay.Day, Hours = 0 } }; //RefreshProperties(); - + //Hier werden im Moment noch nur die eingetragenen Stunden gezählt + //Auf der Website bekommt der Benutzer die berechneten Stunden angezeigt (Nachstunden außerhalb des Stundenplanes zählen mehr ...) TimeSpan span = TimeSpan.Zero; foreach (DayTime dt in _hour.daytime) { span += dt.end - dt.begin; @@ -171,6 +175,8 @@ namespace Jugenddienst_Stunden.ViewModels { ////} } catch (Exception e) { DayTimes = new List(); + DayTotal = new TimeOnly(0); + OnPropertyChanged(nameof(DayTotal)); InfoEvent?.Invoke(this, e.Message); } }