Initial commit: ReminderOrganizer WPF app

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 13:44:02 +01:00
commit 5ca2770829
37 changed files with 3350 additions and 0 deletions

57
Services/DataService.cs Normal file
View File

@@ -0,0 +1,57 @@
#nullable enable
using System;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
using ReminderOrganizer.Models;
namespace ReminderOrganizer.Services
{
public class DataService : IDataService
{
private static readonly JsonSerializerOptions _jsonOptions = new()
{
WriteIndented = true,
PropertyNameCaseInsensitive = true
};
public string DataFilePath { get; }
public DataService()
{
DataFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tasks.json");
}
public async Task<AppData> LoadAsync()
{
if (!File.Exists(DataFilePath))
return new AppData();
try
{
var json = await File.ReadAllTextAsync(DataFilePath);
var data = JsonSerializer.Deserialize<AppData>(json, _jsonOptions);
return data ?? new AppData();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[DataService] Load failed: {ex.Message}");
return new AppData();
}
}
public async Task SaveAsync(AppData data)
{
try
{
var json = JsonSerializer.Serialize(data, _jsonOptions);
await File.WriteAllTextAsync(DataFilePath, json);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[DataService] Save failed: {ex.Message}");
throw;
}
}
}
}