Barcodes speichern

This commit is contained in:
2024-08-21 00:11:59 +02:00
parent a61aa38d24
commit 423e5f3cd2
12 changed files with 142 additions and 49 deletions

View File

@@ -1,6 +1,10 @@

using CommunityToolkit.Mvvm.ComponentModel;
using Newtonsoft.Json;
using System.Text;
namespace Jugenddienst_Stunden.Models {
public class Operator {
public class Operator : ObservableObject {
public string id;
public string name;
public string surname;
@@ -23,5 +27,29 @@ namespace Jugenddienst_Stunden.Models {
public string year;
//public List<int>? timetable;
public static async Task<Operator> LoadData(string apiKey) {
//var apiKey = Preferences.Default.Get("apiKey", "");
Operator OperatorVar = new Operator();
//Operator operator = new Operator();
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");
//throw new Exception("Keine Internetverbindung");
} else {
var tokendata = new TokenData(apiKey);
string data = await Auth.GetApiDataWithAuthAsync(tokendata.url, tokendata.apiKey);
if (data != null) {
OperatorVar = Newtonsoft.Json.JsonConvert.DeserializeObject<Operator>(data);
Preferences.Default.Set("name", OperatorVar.name);
Preferences.Default.Set("surname", OperatorVar.surname);
}
}
return OperatorVar;
}
}
}