Fix unit persistence before saving timetable lessons
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
admin committed 2026-11-09 21:50:36 +01:00
1 parent cbcb739097
commit fb38b6bb04
5 files changed
+53 -1

No files matched your search

@@ -265,6 +265,7 @@ public partial class LessonDialog : Window
chosen = picked;
}
vm.EnsureParentSaved();
chosen.UnitId = vm.UnitId;
chosen.Date = date;
chosen.LessonNumber = vm.LessonNumber;
@@ -121,10 +121,14 @@ public partial class TimetableView : UserControl
App.Services.GetRequiredService<IAttachmentStorage>(),
unit.Id, group.Id, group.Name, subject?.Name ?? "", materials, shorthands,
editingLesson: null, suggestedDate: request.Date, suggestedPeriod: request.PeriodNumber);
if (pickerVm.ResultIsNew)
lessonVm.BeforeSave = () =>
{
if (units.GetById(unit.Id) is null) units.Save(unit);
};
var lessonDialog = new LessonDialog { DataContext = lessonVm };
if (await lessonDialog.ShowDialog<bool>(owner) && lessonVm.Result is not null)
{
if (pickerVm.ResultIsNew) units.Save(unit);
(DataContext as TimetableViewModel)?.Load();
App.Services.GetRequiredService<NotificationService>().ShowSuccess("Stunde angelegt.");
}