Fehlerbehandlung, Logging und feldbezogene Validierung (Kapitel 13.2)

Zentrale Exception-Behandlung (Dispatcher.UIThread.UnhandledException,
AppDomain, TaskScheduler) verhindert Abstürze und protokolliert Fehler
über AppLogger in eine rotierende Log-Datei im App-Datenverzeichnis.
Toast-Benachrichtigungen zeigen Erfolg/Fehler global an. Alle Dialoge
mit Formularfeldern zeigen Validierungsmeldungen jetzt direkt am
betroffenen Feld statt in einem Sammel-Label.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-13 12:38:30 +02:00
co-authored by Claude Sonnet 5
parent 273f459119
commit db1afff7e4
27 changed files with 578 additions and 102 deletions
@@ -315,11 +315,16 @@ public partial class StudentGradesDialogViewModel : ObservableObject
private void Save(GradeEditItem item)
{
if (string.IsNullOrWhiteSpace(item.Value)) { item.ValidationMessage = "Wert darf nicht leer sein."; return; }
item.ValueError = ""; item.DateTextError = "";
var valid = true;
if (string.IsNullOrWhiteSpace(item.Value)) { item.ValueError = "Wert darf nicht leer sein."; valid = false; }
if (!DateOnly.TryParseExact(item.DateText, "dd.MM.yyyy", null,
System.Globalization.DateTimeStyles.None, out _))
{ item.ValidationMessage = "Datum im Format TT.MM.JJJJ eingeben."; return; }
item.ValidationMessage = "";
{ item.DateTextError = "Format TT.MM.JJJJ."; valid = false; }
if (!valid) return;
var grade = item.ToModel();
_grades.Save(grade);
item.IsNew = false;
@@ -345,7 +350,8 @@ public partial class GradeEditItem : ObservableObject
[ObservableProperty] private string _dateText;
[ObservableProperty] private double _weight;
[ObservableProperty] private string? _note;
[ObservableProperty] private string _validationMessage = "";
[ObservableProperty] private string _valueError = "";
[ObservableProperty] private string _dateTextError = "";
// Für die ComboBox: deutsche Anzeige statt des rohen Enum-Namens.
public string CategoryName
@@ -405,7 +411,7 @@ public partial class CollectiveGradeDialogViewModel : ObservableObject
[ObservableProperty] private double _weight = 1.0;
[ObservableProperty] private string? _note;
[ObservableProperty] private string _statusMessage = "";
[ObservableProperty] private string _validationMessage = "";
[ObservableProperty] private string _dateTextError = "";
// Für die ComboBox: deutsche Anzeige statt des rohen Enum-Namens.
public string CategoryName
@@ -428,8 +434,8 @@ public partial class CollectiveGradeDialogViewModel : ObservableObject
{
if (!DateOnly.TryParseExact(DateText, "dd.MM.yyyy", null,
System.Globalization.DateTimeStyles.None, out var date))
{ ValidationMessage = "Datum im Format TT.MM.JJJJ eingeben."; return; }
ValidationMessage = "";
{ DateTextError = "Format TT.MM.JJJJ."; return; }
DateTextError = "";
var count = 0;
foreach (var row in Rows)