Initial commit
This commit is contained in:
29
Jugenddienst Stunden/Models/Stunde.cs
Normal file
29
Jugenddienst Stunden/Models/Stunde.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user