Barcodes speichern
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user