init 1.0.0

This commit is contained in:
2026-06-19 00:42:00 +02:00
commit 5ca960746b
67 changed files with 3261 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
using System.Text.Json;
using LehrerApp.Core.Models;
namespace LehrerApp.Api;
public class ReadableSnapshotStore(string dataPath)
{
private readonly string _path = Path.Combine(dataPath, "readable");
private static readonly JsonSerializerOptions _opts = new() { WriteIndented = false, PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
public void Store(string userId, ReadableSnapshot snap)
{
Directory.CreateDirectory(_path);
File.WriteAllText(FilePath(userId), JsonSerializer.Serialize(snap, _opts));
}
public ReadableSnapshot? Load(string userId)
{
var p = FilePath(userId);
return File.Exists(p) ? JsonSerializer.Deserialize<ReadableSnapshot>(File.ReadAllText(p), _opts) : null;
}
private string FilePath(string userId) =>
Path.Combine(_path, $"{string.Concat(userId.Where(c => char.IsLetterOrDigit(c) || c == '-'))}.json");
}