30 lines
807 B
C#
30 lines
807 B
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using Newtonsoft.Json;
|
|
|
|
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
|
|
private static readonly string requestUrl = $"{BaseAddress}/appapi?hours";
|
|
|
|
public DateTime Date { get; set; }
|
|
|
|
|
|
|
|
public static async Task<Hours> LoadData() {
|
|
string data = await Auth.GetApiDataWithAuthAsync(requestUrl, apiKey);
|
|
|
|
if(data == null) {
|
|
throw new Exception("Keine Daten erhalten");
|
|
}
|
|
|
|
Hours hours = JsonConvert.DeserializeObject<Hours>(data);
|
|
|
|
return hours ?? new Hours();
|
|
}
|
|
|
|
|
|
}
|
|
}
|