Vorbereitungen für 1.0.6

Beachte die Einstellung ob Projekte und Gemeinden aktiv sind.
Verbiete Änderungen an der Freistellung, wenn sie genehmigt wurde.
Vereinfache das Speichern der Einstellungen
Bessere Fehlerbehandlung, einheitlichere API
This commit is contained in:
2024-10-22 17:42:35 +02:00
parent ff145b2c7f
commit 45c53c85ce
11 changed files with 350 additions and 293 deletions

View File

@@ -1,7 +1,5 @@
using Jugenddienst_Stunden.Types;
using Newtonsoft.Json;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Text;
using System.Text.Json;
@@ -77,8 +75,9 @@ internal static class BaseFunc {
// Lesen und Rückgabe der Antwort als String
string responseData = await HttpContent.ReadAsStringAsync();
User userData = System.Text.Json.JsonSerializer.Deserialize<User>(responseData) ?? throw new Exception("Fehler beim Deserialisieren der Daten");
return userData;
BaseResponse res = JsonConvert.DeserializeObject<BaseResponse>(responseData) ?? throw new Exception("Fehler beim Deserialisieren der Daten");
//User userData = System.Text.Json.JsonSerializer.Deserialize<User>(responseData) ?? throw new Exception("Fehler beim Deserialisieren der Daten");
return res.user;
}
}
}
@@ -90,7 +89,7 @@ internal static class BaseFunc {
internal static HoursBase Load(string filename) {
internal static Note Load(string filename) {
filename = System.IO.Path.Combine(FileSystem.AppDataDirectory, filename);
if (!File.Exists(filename))
@@ -98,8 +97,6 @@ internal static class BaseFunc {
return
new() {
//Filename = Path.GetFileName(filename),
//Text = File.ReadAllText(filename),
Date = File.GetLastWriteTime(filename)
};
}
@@ -129,11 +126,11 @@ internal static class BaseFunc {
}
//Gemeinde ist ein Pflichtfeld
if (item.GemeindeAktiv == null) {
if (item.GemeindeAktiv == null && GlobalVar.Settings.GemeindeAktivSet) {
throw new Exception("Gemeinde nicht gewählt");
}
//Projekt ist ein Pflichtfeld
if (item.ProjektAktiv == null) {
if (item.ProjektAktiv == null && GlobalVar.Settings.ProjektAktivSet) {
throw new Exception("Projekt nicht gewählt");
}
//Keine Beschreibung