Refactor Api-Client

Add Exceptionhandler, AlertService JSON-Converter
AppSettings via DI

Reformat Code
This commit is contained in:
2025-12-17 09:34:08 +01:00
parent 544b0c9591
commit 76eb71946f
84 changed files with 3178 additions and 2191 deletions

View File

@@ -1,36 +1,37 @@
using Jugenddienst_Stunden.Models;
namespace Jugenddienst_Stunden.Types;
internal class BaseResponse {
public Settings settings { get; set; }
public Settings settings { get; set; }
/// <summary>
/// Monatsübersicht
/// </summary>
public Hours hour { get; set; }
/// <summary>
/// Monatsübersicht
/// </summary>
public Hours hour { get; set; }
/// <summary>
/// Stundenliste ... für die Katz?
/// </summary>
public List<Hours> hours { get; set; }
/// <summary>
/// Stundenliste ... für die Katz?
/// </summary>
public List<Hours> hours { get; set; }
/// <summary>
/// Liste der Stundeneinträge
/// </summary>
public List<DayTime> daytimes { get; set; }
/// <summary>
/// Liste der Stundeneinträge
/// </summary>
public List<DayTime> daytimes { get; set; }
/// <summary>
/// Einzelner Stundeneintrag
/// </summary>
public DayTime daytime { get; set; }
/// <summary>
/// Einzelner Stundeneintrag
/// </summary>
public DayTime daytime { get; set; }
/// <summary>
/// Auch irgendwie doppelt ...
/// </summary>
public Operator operatorVar { get; set; }
public User user { get; set; }
/// <summary>
/// Auch irgendwie doppelt ...
/// </summary>
public Operator operatorVar { get; set; }
public int error { get; set; }
public string message { get; set; }
}
public User user { get; set; }
public int error { get; set; }
public string message { get; set; }
}

View File

@@ -2,95 +2,95 @@
using System.Collections.ObjectModel;
namespace Jugenddienst_Stunden.Types;
/// <summary>
/// Represents a day time entry for an employee.
/// </summary>
public class DayTime {
/// <summary>
/// ID des Stundeneintrages
/// </summary>
public int? Id { get; set; }
/// <summary>
/// ID des Stundeneintrages
/// </summary>
public int? Id { get; set; }
/// <summary>
/// Mitarbeiter-ID
/// </summary>
public int EmployeeId { get; set; }
/// <summary>
/// Mitarbeiter-ID
/// </summary>
public int EmployeeId { get; set; }
/// <summary>
/// Der betreffende Tag
/// </summary>
public DateTime Day { get; set; }
/// <summary>
/// Der betreffende Tag
/// </summary>
public DateTime Day { get; set; }
/// <summary>
/// Der Wochentag
/// </summary>
public int Wday { get; set; }
/// <summary>
/// Der Wochentag
/// </summary>
public int Wday { get; set; }
/// <summary>
/// Arbeitsbeginn
/// </summary>
public TimeOnly Begin { get; set; }
/// <summary>
/// Arbeitsbeginn
/// </summary>
public TimeOnly Begin { get; set; }
/// <summary>
/// Arbeitsende
/// </summary>
public TimeOnly End { get; set; }
/// <summary>
/// Arbeitsende
/// </summary>
public TimeOnly End { get; set; }
/// <summary>
/// Beschreibung der Tätigkeit
/// </summary>
public string? Description { get; set; }
/// <summary>
/// Beschreibung der Tätigkeit
/// </summary>
public string? Description { get; set; }
/// <summary>
/// Freistellung
/// </summary>
public string? Free { get; set; }
/// <summary>
/// Freistellung
/// </summary>
public string? Free { get; set; }
/// <summary>
/// Freistellung genehmigt?
/// </summary>
public bool Approved { get; set; }
/// <summary>
/// Freistellung genehmigt?
/// </summary>
public bool Approved { get; set; }
/// <summary>
/// Das gewählte Projekt
/// </summary>
public int? Projekt { get; set; }
/// <summary>
/// Das gewählte Projekt
/// </summary>
public int? Projekt { get; set; }
/// <summary>
/// Die gewählte Gemeinde
/// </summary>
public int? Gemeinde { get; set; }
/// <summary>
/// Die gewählte Gemeinde
/// </summary>
public int? Gemeinde { get; set; }
/// <summary>
/// Nachtstunden
/// </summary>
public TimeOnly Night { get; set; }
/// <summary>
/// Nachtstunden
/// </summary>
public TimeOnly Night { get; set; }
/// <summary>
/// Summe Arbeitszeit (inklusive Nachstunden mit Faktor)
/// </summary>
public Dictionary<string, TimeOnly> Total { get; set; }
/// <summary>
/// Summe Arbeitszeit (inklusive Nachstunden mit Faktor)
/// </summary>
public Dictionary<string, TimeOnly> Total { get; set; }
public TimeOnly End_print { get; set; }
public TimeSpan TimeSpanVon { get; set; }
public TimeSpan TimeSpanBis { get; set; }
public TimeOnly End_print { get; set; }
public TimeSpan TimeSpanVon { get; set; }
public TimeSpan TimeSpanBis { get; set; }
/// <summary>
/// Gets the active Gemeinde based on the gemeinde ID.
/// </summary>
public Gemeinde? GemeindeAktiv { get; set; }
/// <summary>
/// Gets the active Gemeinde based on the gemeinde ID.
/// </summary>
public Gemeinde? GemeindeAktiv { get; set; }
/// <summary>
/// Gets the active Projekt based on the projekt ID.
/// </summary>
public Projekt? ProjektAktiv { get; set; }
/// <summary>
/// Gets the active Projekt based on the projekt ID.
/// </summary>
public Projekt? ProjektAktiv { get; set; }
/// <summary>
/// Gets the active Freistellung based on the Freistellung ID
/// </summary>
public Freistellung? FreistellungAktiv { get; set; }
/// <summary>
/// Gets the active Freistellung based on the Freistellung ID
/// </summary>
public Freistellung? FreistellungAktiv { get; set; }
public int TimeTable { get; set; }
}
public int TimeTable { get; set; }
}

View File

@@ -1,8 +1,9 @@
namespace Jugenddienst_Stunden.Types;
/// <summary>
/// Freistellungen: Urlaub, Zeitausgleich, Krankheit, ...
/// </summary>
public class Freistellung {
public string? Id { get; set; }
public string? Id { get; set; }
public string? Name { get; set; }
}
}

View File

@@ -13,4 +13,4 @@ public class Gemeinde {
/// Name der Gemeinde.
/// </summary>
public string? Name { get; set; }
}
}

View File

@@ -1,43 +1,45 @@

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
namespace Jugenddienst_Stunden.Types;
internal partial class Hours : ObservableObject {
public partial class Hours : ObservableObject {
public double? Zeit;
public double? Nominal;
//public Dictionary<DateOnly,NominalDay> nominal_day_api;
public List<NominalDay>? Nominal_day_api;
//public Dictionary<int,NominalWeek> nominal_week_api;
public List<NominalWeek>? Nominal_week_api;
//public List<string> time_line;
public double? Zeit_total;
//https://stackoverflow.com/questions/29449641/deserialize-json-when-a-value-can-be-an-object-or-an-empty-array/29450279#29450279
//[JsonConverter(typeof(JsonSingleOrEmptyArrayConverter<Hours>))]
//public Dictionary<int,decimal> zeit_total_daily;
//public List<string> time_line;
public double? Zeit_total;
public List<TimeDay> zeit_total_daily_api;
//https://stackoverflow.com/questions/29449641/deserialize-json-when-a-value-can-be-an-object-or-an-empty-array/29450279#29450279
//[JsonConverter(typeof(JsonSingleOrEmptyArrayConverter<Hours>))]
//public Dictionary<int,decimal> zeit_total_daily;
public List<TimeDay> zeit_total_daily_api;
public List<DayTime>? daytime;
//public List<string> wochensumme;
//public List<string> wochensumme;
[ObservableProperty]
public double overtime_month;
[ObservableProperty] public double overtime_month;
[ObservableProperty]
public double overtime;
//public List<string> overtime_day;
[ObservableProperty] public double overtime;
//public List<string> overtime_day;
[ObservableProperty]
public double zeitausgleich;
[ObservableProperty] public double zeitausgleich;
public double zeitausgleich_month;
public double holiday;
public double krankheit;
public double weiterbildung;
public double bereitschaft;
public double bereitschaft_month;
//public Operator operator_api;
public DateTime Today;
public DateTime Date;
@@ -47,5 +49,4 @@ internal partial class Hours : ObservableObject {
public Collection<Gemeinde> Gemeinden { get; set; }
public Collection<Freistellung> Freistellungen { get; set; }
public int EmployeeId { get; set; }
}
}

View File

@@ -1,7 +1,8 @@
namespace Jugenddienst_Stunden.Types;
internal class NominalDay {
public class NominalDay {
public int day_number;
public int month_number;
public double hours;
public DateOnly date;
}
}

View File

@@ -1,6 +1,6 @@
namespace Jugenddienst_Stunden.Types;
internal class NominalWeek {
public int Week_number;
public double Hours;
}
public class NominalWeek {
public int Week_number;
public double Hours;
}

View File

@@ -13,4 +13,4 @@ public class Projekt {
/// Holt oder setzt den Namen des Projekts.
/// </summary>
public string Name { get; set; }
}
}

View File

@@ -4,35 +4,35 @@
/// Einstellungen
/// </summary>
public class Settings {
/// <summary>
/// Sind Projekte aktiv?
/// </summary>
public bool ProjektAktivSet { get; set; }
/// <summary>
/// Sind Projekte aktiv?
/// </summary>
public bool ProjektAktivSet { get; set; }
/// <summary>
/// Sind Gemeinden aktiv?
/// </summary>
public bool GemeindeAktivSet { get; set; }
/// <summary>
/// Sind Gemeinden aktiv?
/// </summary>
public bool GemeindeAktivSet { get; set; }
/// <summary>
/// Liste der Projekte
/// </summary>
public List<Projekt>? Projekte { get; set; }
/// <summary>
/// Liste der Projekte
/// </summary>
public List<Projekt>? Projekte { get; set; }
/// <summary>
/// Liste der Gemeinden
/// </summary>
public List<Gemeinde>? Gemeinden { get; set; }
/// <summary>
/// Liste der Gemeinden
/// </summary>
public List<Gemeinde>? Gemeinden { get; set; }
/// <summary>
/// Liste der Freistellungen
/// </summary>
public List<Freistellung>? Freistellungen { get; set; }
/// <summary>
/// Liste der Freistellungen
/// </summary>
public List<Freistellung>? Freistellungen { get; set; }
public List<Sollstunden> Nominal { get; set; }
public List<Sollstunden>? Nominal { get; set; }
/// <summary>
/// Version der API
/// </summary>
public string Version { get; set; }
}
/// <summary>
/// Version der API
/// </summary>
public string? Version { get; set; }
}

View File

@@ -1,7 +1,7 @@
namespace Jugenddienst_Stunden.Types;
public class Sollstunden {
public int Timetable { get; set; }
public int Wochentag { get; set; }
public double Zeit { get; set; }
}
public int Timetable { get; set; }
public int Wochentag { get; set; }
public double Zeit { get; set; }
}

View File

@@ -3,7 +3,7 @@
/// <summary>
/// Summe der geleisteten Stunden.
/// </summary>
internal struct TimeDay {
public int Day { get; set; }
public double Hours { get; set; }
}
public struct TimeDay {
public int Day { get; set; }
public double Hours { get; set; }
}

View File

@@ -1,6 +1,6 @@
namespace Jugenddienst_Stunden.Types;
internal class Timetable {
public List<TimetableEntry> timetable;
public decimal wochensumme;
}
public List<TimetableEntry> timetable;
public decimal wochensumme;
}

View File

@@ -1,7 +1,7 @@
namespace Jugenddienst_Stunden.Types;
internal class TimetableEntry {
public List<TimeOnly>? Von;
public List<TimeOnly>? Bis;
public decimal Summe { get; set; }
}
public List<TimeOnly>? Von;
public List<TimeOnly>? Bis;
public decimal Summe { get; set; }
}

View File

@@ -1,7 +1,8 @@
namespace Jugenddienst_Stunden.Types;
internal class User {
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public string Token { get; set; }
}
}