Show error if not logged in

This commit is contained in:
2024-09-27 11:16:27 +02:00
parent ec7f563bc0
commit 5f3e80dcc7
2 changed files with 16 additions and 8 deletions

View File

@@ -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<Hours> 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<List<DayTime>> LoadDay(DateTime date) {
if (string.IsNullOrEmpty(apiKey)) {
throw new Exception("Kein APIKEY, bitte zuerst Login durchführen");
}
List<DayTime> daytimes = new List<DayTime>();
if (Connectivity.Current.NetworkAccess == NetworkAccess.None) {
@@ -122,7 +126,6 @@ namespace Jugenddienst_Stunden.Models {
return daytimes;
}
public static async Task<DayTime> 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);