Namespaceanpassungen
This commit is contained in:
@@ -4,50 +4,49 @@ using Jugenddienst_Stunden.ViewModels;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
|
||||
namespace Jugenddienst_Stunden.Models {
|
||||
public class Operator : ObservableObject {
|
||||
public string id;
|
||||
public string name;
|
||||
public string surname;
|
||||
public string email;
|
||||
public string password;
|
||||
public string lang;
|
||||
public string admin;
|
||||
public string aktiv;
|
||||
public string department;
|
||||
public string department_name;
|
||||
public string num;
|
||||
public string year;
|
||||
namespace Jugenddienst_Stunden.Models;
|
||||
public class Operator : ObservableObject {
|
||||
public string id;
|
||||
public string name;
|
||||
public string surname;
|
||||
public string email;
|
||||
public string password;
|
||||
public string lang;
|
||||
public string admin;
|
||||
public string aktiv;
|
||||
public string department;
|
||||
public string department_name;
|
||||
public string num;
|
||||
public string year;
|
||||
|
||||
|
||||
public event EventHandler<string> AlertEvent;
|
||||
public event EventHandler<string> AlertEvent;
|
||||
|
||||
public static async Task<Operator> LoadData(string apiKey) {
|
||||
public static async Task<Operator> LoadData(string apiKey) {
|
||||
|
||||
Operator OperatorVar = 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);
|
||||
|
||||
//try {
|
||||
string data = await Auth.GetApiDataWithAuthAsync(tokendata.url, tokendata.apiKey);
|
||||
if (data == "\"Lalala\"") {
|
||||
throw new Exception("Problem mit Token");
|
||||
}
|
||||
if (data != "null") {
|
||||
OperatorVar = JsonConvert.DeserializeObject<Operator>(data);
|
||||
Preferences.Default.Set("name", OperatorVar.name);
|
||||
Preferences.Default.Set("surname", OperatorVar.surname);
|
||||
Preferences.Default.Set("apiUrl", tokendata.url);
|
||||
}
|
||||
Operator OperatorVar = 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);
|
||||
|
||||
//try {
|
||||
string data = await Auth.GetApiDataWithAuthAsync(tokendata.url, tokendata.apiKey);
|
||||
if (data == "\"Lalala\"") {
|
||||
throw new Exception("Problem mit Token");
|
||||
}
|
||||
return OperatorVar;
|
||||
if (data != "null") {
|
||||
OperatorVar = JsonConvert.DeserializeObject<Operator>(data);
|
||||
Preferences.Default.Set("name", OperatorVar.name);
|
||||
Preferences.Default.Set("surname", OperatorVar.surname);
|
||||
Preferences.Default.Set("apiUrl", tokendata.url);
|
||||
}
|
||||
|
||||
}
|
||||
return OperatorVar;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user