using Avalonia.Controls; using LehrerApp.Core.Interfaces; using LehrerApp.Core.Models; using LehrerApp.Core.Services; using LehrerApp.Desktop.ViewModels.Groups; using LehrerApp.Desktop.Views.Groups; using LehrerApp.Templating; using Microsoft.Extensions.DependencyInjection; namespace LehrerApp.Desktop.Services; /// Öffnet den Deckblatt-Dialog zu einer Klausur — ein Einstieg für die Klausuren- /// Hauptseite und den Klausuren-Tab der Lerngruppe. public static class ExamCoverSheetDialogs { public static async Task ShowAsync(Control source, Exam exam) { var group = App.Services.GetRequiredService().GetById(exam.GroupId); if (group is null || TopLevel.GetTopLevel(source) is not Window owner) return; var subject = group.SubjectId is { } subjectId ? App.Services.GetRequiredService().GetById(subjectId)?.Name ?? "" : ""; var vm = new ExamCoverSheetDialogViewModel(exam, group, subject, App.Services.GetRequiredService(), App.Services.GetRequiredService(), App.Services.GetRequiredService(), App.Services.GetRequiredService(), [App.Services.GetRequiredService(), App.Services.GetRequiredService().Store], App.Services.GetRequiredService(), App.Services.GetRequiredService().LoadAbbreviation()); await new ExamCoverSheetDialog { DataContext = vm }.ShowDialog(owner); } }