using System.Text.Json;
using LehrerApp.Core.Models;
namespace LehrerApp.Core.Services;
internal class SchoolCalendarConfig
{
public GermanState State { get; set; } = GermanState.NW;
}
/// Welches Bundesland für die Feiertagsberechnung (4.3.5) gilt.
public class SchoolCalendarSettingsService
{
private readonly string _configPath;
private SchoolCalendarConfig _config;
public GermanState State => _config.State;
public SchoolCalendarSettingsService(string appDataPath)
{
_configPath = Path.Combine(appDataPath, "schoolcalendar.json");
_config = Load();
}
public void SetState(GermanState state)
{
_config.State = state;
File.WriteAllText(_configPath, JsonSerializer.Serialize(_config));
}
private SchoolCalendarConfig Load()
{
try
{
if (File.Exists(_configPath))
return JsonSerializer.Deserialize(File.ReadAllText(_configPath))
?? new SchoolCalendarConfig();
}
catch { /* beschädigte Konfiguration -> Standardwert */ }
return new SchoolCalendarConfig();
}
}