Barcodes speichern
This commit is contained in:
@@ -2,35 +2,48 @@
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.Maui.Networking;
|
||||
using Microsoft.Maui.Controls;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace Jugenddienst_Stunden.Models {
|
||||
internal class Stunde : ObservableObject {
|
||||
|
||||
private static readonly string BaseAddress = "http://hours.dauni.mine.nu:81";
|
||||
//private static readonly string apiKey = "MTQzfEFlMVRjQXdZMnI4RmpxZ0FSY3A0VEN2bVZYVXxodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk="; //Christine
|
||||
public static string apiKey = "MTU0fGpkQUNYTGkvcjMvVk4rNkMyK0dDQkJmMkFwVXxodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk="; //Damian
|
||||
private static readonly string requestUrl = $"{BaseAddress}/appapi?hours";
|
||||
//Katharina
|
||||
public static string apiKey = Preferences.Default.Get("apiKey", "MTAyfEJZZnB1L3VwcnhoVms0dDlLZENPZWtUVy85b3xodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk=");
|
||||
|
||||
//Damian
|
||||
//public static string apiKey = Preferences.Default.Get("apiKey", "MTU0fGpkQUNYTGkvcjMvVk4rNkMyK0dDQkJmMkFwVXxodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk=");
|
||||
|
||||
//private static readonly string requestUrl = $"{BaseAddress}/appapi?hours";
|
||||
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
|
||||
|
||||
public static async Task<Hours> LoadData() {
|
||||
|
||||
public static async Task<Hours> LoadData() {
|
||||
|
||||
Hours hours = new Hours();
|
||||
|
||||
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 {
|
||||
string data = await Auth.GetApiDataWithAuthAsync(requestUrl, apiKey);
|
||||
var tokendata = new TokenData(apiKey);
|
||||
|
||||
//string data = await Auth.GetApiDataWithAuthAsync(requestUrl, apiKey);
|
||||
string data = await Auth.GetApiDataWithAuthAsync(tokendata.url + "?hours", tokendata.apiKey);
|
||||
|
||||
if (data == null) {
|
||||
throw new Exception("Keine Daten erhalten");
|
||||
}
|
||||
|
||||
hours = JsonConvert.DeserializeObject<Hours>(data);
|
||||
//Preferences.Default.Set("name", hours.operator_api.name);
|
||||
//Preferences.Default.Set("surname", hours.operator_api.surname);
|
||||
|
||||
|
||||
}
|
||||
return hours;
|
||||
|
||||
Reference in New Issue
Block a user