70 lines
2.2 KiB
C#
70 lines
2.2 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;
|
||
|
|
||
|
namespace kursovaya;
|
||
|
|
||
|
public partial class AdminWindow : Window
|
||
|
{
|
||
|
List<Discipline> Disciplines = new List<Discipline>();
|
||
|
List<Group> Groups = new List<Group>();
|
||
|
List<Teacher> Teachers = new List<Teacher>();
|
||
|
ObservableCollection<DisciplineGroupTeacher> DisciplineGroupTeachers = new ObservableCollection<DisciplineGroupTeacher>();
|
||
|
public AdminWindow()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
|
||
|
var ctx = new DatabaseContext();
|
||
|
|
||
|
Disciplines = ctx.Disciplines.ToList();
|
||
|
Groups = ctx.Groups.ToList();
|
||
|
Teachers = ctx.Teachers.ToList();
|
||
|
|
||
|
var disciplineTeachers = ctx.DisciplineTeachers.ToList();
|
||
|
|
||
|
foreach (DisciplineTeacher disciplineTeacher in disciplineTeachers)
|
||
|
{
|
||
|
//todo
|
||
|
//var group =
|
||
|
var teacher = ctx.Teachers.FirstOrDefault(t => t.Id == disciplineTeacher.IdTeacher);
|
||
|
var discipline = ctx.Disciplines.FirstOrDefault(d => d.Id == disciplineTeacher.IdDiscipline);
|
||
|
DisciplineGroupTeachers.Add(new DisciplineGroupTeacher(){Teacher = teacher, Discipline = discipline, Group = new Group() {Id = 777, YearAdmission = 777}});
|
||
|
}
|
||
|
|
||
|
GroupComboBox.ItemsSource = Groups.Select(g => g.Id);
|
||
|
DisciplineComboBox.ItemsSource = Disciplines.Select(d => d.Name);
|
||
|
TeacherComboBox.ItemsSource = Teachers.Select(t => t.Fio);
|
||
|
FlatGrid.ItemsSource = DisciplineGroupTeachers;
|
||
|
|
||
|
}
|
||
|
|
||
|
public class DisciplineGroupTeacher()
|
||
|
{
|
||
|
public Group Group { get; set; }
|
||
|
public Discipline Discipline { get; set; }
|
||
|
public Teacher Teacher { get; set; }
|
||
|
|
||
|
public string DisciplineName
|
||
|
{
|
||
|
get => Discipline.Name;
|
||
|
}
|
||
|
public string TeacherFio
|
||
|
{
|
||
|
get => Teacher.Fio;
|
||
|
}
|
||
|
public int GroupId
|
||
|
{
|
||
|
get => Group.Id;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
|
||
|
{
|
||
|
Close();
|
||
|
}
|
||
|
}
|