Files
LehrerApp/LehrerApp.Desktop/Views/Groups/ReportGradeDialog.axaml.cs

26 lines
889 B
C#

using Avalonia.Controls;
using Avalonia.Interactivity;
using LehrerApp.Desktop.Services;
using LehrerApp.Desktop.ViewModels.Groups;
using Microsoft.Extensions.DependencyInjection;
namespace LehrerApp.Desktop.Views.Groups;
public partial class ReportGradeDialog : Window
{
public ReportGradeDialog() => InitializeComponent();
private async void OnExportClick(object? sender, RoutedEventArgs e)
{
if (DataContext is not ReportGradeDialogViewModel vm) return;
var topLevel = TopLevel.GetTopLevel(this);
if (topLevel is null) return;
var export = ExportFile.Csv("Zeugnisnoten exportieren",
$"Zeugnisnoten_{vm.GroupLabel}.csv", vm.ExportCsv());
await App.Services.GetRequiredService<ExportService>().SaveAsync(topLevel.StorageProvider, export);
}
private void OnClose(object? sender, RoutedEventArgs e) => Close();
}