56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Markup.Xaml;
|
|
using kursovaya.Models;
|
|
using Microsoft.EntityFrameworkCore.Scaffolding.Metadata;
|
|
|
|
namespace kursovaya;
|
|
|
|
public partial class GroupsFromAdminWindow : Window
|
|
{
|
|
public List<Group> dataSourceGroups = new List<Group>();
|
|
public ObservableCollection<Group> Groups = new ObservableCollection<Group>();
|
|
public GroupsFromAdminWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
var ctx = new DatabaseContext();
|
|
|
|
dataSourceGroups = ctx.Groups.ToList();
|
|
DisplayGroups();
|
|
FlatGrid.ItemsSource = Groups;
|
|
}
|
|
|
|
public void DisplayGroups()
|
|
{
|
|
var ctx = new DatabaseContext();
|
|
var temp = dataSourceGroups;
|
|
Groups.Clear();
|
|
|
|
foreach (var group in temp)
|
|
{
|
|
Groups.Add(group);
|
|
}
|
|
}
|
|
|
|
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private async void ButtonAddGroup_OnClick(object? sender, RoutedEventArgs e)
|
|
{
|
|
AddGroup addGroup = new AddGroup();
|
|
var groups = await addGroup.ShowDialog<List<Group>>(this);
|
|
if (groups == null || groups.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
dataSourceGroups.AddRange(groups);
|
|
DisplayGroups();
|
|
}
|
|
} |