Mitarbeit bewerten begonnen, Schülerdaten, Gruppen
This commit is contained in:
@@ -1,3 +1,35 @@
|
||||
using Avalonia.Controls;
|
||||
using LehrerApp.Core.Interfaces;
|
||||
using LehrerApp.Desktop.ViewModels.Groups;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace LehrerApp.Desktop.Views.Groups;
|
||||
public partial class GroupDetailView : UserControl { public GroupDetailView() => InitializeComponent(); }
|
||||
|
||||
public partial class GroupDetailView : UserControl
|
||||
{
|
||||
public GroupDetailView() => InitializeComponent();
|
||||
|
||||
protected override void OnDataContextChanged(EventArgs e)
|
||||
{
|
||||
base.OnDataContextChanged(e);
|
||||
if (DataContext is GroupDetailViewModel vm)
|
||||
vm.OnAddStudent = ShowAddStudentDialog;
|
||||
}
|
||||
|
||||
private async Task<bool> ShowAddStudentDialog()
|
||||
{
|
||||
if (DataContext is not GroupDetailViewModel vm || vm.Group is null) return false;
|
||||
|
||||
var dialogVm = new AddStudentToGroupDialogViewModel(
|
||||
App.Services.GetRequiredService<IStudentRepository>(),
|
||||
App.Services.GetRequiredService<IEnrollmentRepository>(),
|
||||
vm.Group.Id,
|
||||
vm.Group.SchoolYear);
|
||||
|
||||
var dialog = new AddStudentToGroupDialog { DataContext = dialogVm };
|
||||
var owner = TopLevel.GetTopLevel(this) as Window;
|
||||
if (owner is null) return false;
|
||||
|
||||
return await dialog.ShowDialog<bool>(owner);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user