46 lines
1.7 KiB
C#
46 lines
1.7 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using LehrerApp.Core.Interfaces;
|
|
using LehrerApp.Core.Models;
|
|
using LehrerApp.Core.Services;
|
|
using LehrerApp.Desktop.Services;
|
|
using LehrerApp.Desktop.ViewModels;
|
|
using LehrerApp.Desktop.ViewModels.Students;
|
|
using LehrerApp.Desktop.Views.Students;
|
|
using LehrerApp.Desktop.Views.Workload;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace LehrerApp.Desktop.Views.Dashboard;
|
|
|
|
public partial class DashboardView : UserControl
|
|
{
|
|
public DashboardView() => InitializeComponent();
|
|
|
|
protected override void OnDataContextChanged(EventArgs e)
|
|
{
|
|
base.OnDataContextChanged(e);
|
|
if (DataContext is DashboardViewModel vm)
|
|
vm.OnAddTask = ShowAddTaskDialog;
|
|
}
|
|
|
|
private async Task<WorkTask?> ShowAddTaskDialog(bool startAsReminder)
|
|
{
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner is null) return null;
|
|
return await WorkTaskDialogHelper.ShowDialog(owner, startAsReminder: startAsReminder);
|
|
}
|
|
|
|
private async void OnCompareWebUntisDocumentationClick(object? sender, RoutedEventArgs e)
|
|
{
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner is null) return;
|
|
var dialogVm = new WebUntisDocumentationComparisonViewModel(
|
|
App.Services.GetRequiredService<WebUntisIntegrationService>(),
|
|
App.Services.GetRequiredService<IStudentRepository>(),
|
|
App.Services.GetRequiredService<IGroupRepository>(),
|
|
App.Services.GetRequiredService<IDocumentationRepository>(),
|
|
App.Services.GetRequiredService<SchoolYearService>());
|
|
await new WebUntisDocumentationComparisonDialog { DataContext = dialogVm }.ShowDialog(owner);
|
|
}
|
|
}
|