Add shared export infrastructure
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using LehrerApp.Desktop.Services;
|
||||
using LehrerApp.Desktop.ViewModels.Groups;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace LehrerApp.Desktop.Views.Groups;
|
||||
|
||||
@@ -15,15 +16,9 @@ public partial class ExamEvaluationDialog : Window
|
||||
var topLevel = TopLevel.GetTopLevel(this);
|
||||
if (topLevel is null) return;
|
||||
|
||||
var file = await topLevel.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Title = "Klausurauswertung exportieren",
|
||||
SuggestedFileName = $"Auswertung_{vm.ExamTitle}.csv",
|
||||
FileTypeChoices = [new FilePickerFileType("CSV-Dateien") { Patterns = ["*.csv"] }],
|
||||
});
|
||||
|
||||
if (file is null) return;
|
||||
await File.WriteAllTextAsync(file.Path.LocalPath, vm.ExportCsv());
|
||||
var export = ExportFile.Csv("Klausurauswertung exportieren",
|
||||
$"Auswertung_{vm.ExamTitle}.csv", vm.ExportCsv());
|
||||
await App.Services.GetRequiredService<ExportService>().SaveAsync(topLevel.StorageProvider, export);
|
||||
}
|
||||
|
||||
private void OnClose(object? sender, RoutedEventArgs e) => Close();
|
||||
|
||||
Reference in New Issue
Block a user