done;withLogsConsole
This commit is contained in:
parent
d7abb5ffd6
commit
174854d4ba
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
@ -5,6 +6,7 @@ using Avalonia.Controls;
|
|||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using kursovaya.Models;
|
using kursovaya.Models;
|
||||||
|
using kursovaya.ModelsLocal;
|
||||||
|
|
||||||
namespace kursovaya;
|
namespace kursovaya;
|
||||||
|
|
||||||
@ -14,6 +16,7 @@ public partial class AddTeacher : Window
|
|||||||
Teacher _teacher = new Teacher();
|
Teacher _teacher = new Teacher();
|
||||||
List<Teacher> _teachers = new List<Teacher>();
|
List<Teacher> _teachers = new List<Teacher>();
|
||||||
|
|
||||||
|
List<DisciplineGroupTeacher> _disciplineGroupTeachers = new List<DisciplineGroupTeacher>();
|
||||||
public AddTeacher()
|
public AddTeacher()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -54,10 +57,41 @@ public partial class AddTeacher : Window
|
|||||||
|
|
||||||
foreach (var item in selectedItems)
|
foreach (var item in selectedItems)
|
||||||
{
|
{
|
||||||
|
var studentsId = ctx.Attestations.Where(it => it.IdDiscipline == item.Discipline.Id).Select(it => it.IdUser).ToList();
|
||||||
|
foreach (var id in studentsId)
|
||||||
|
{
|
||||||
|
var groupId = ctx.Students
|
||||||
|
.Where(s => s.Id == id)
|
||||||
|
.Select(s => s.IdGroup)
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
|
var group = ctx.Groups.FirstOrDefault(g => g.Id == groupId);
|
||||||
|
|
||||||
|
bool alreadyExists = _disciplineGroupTeachers.Any(dgt =>
|
||||||
|
dgt.Group.Id == group.Id &&
|
||||||
|
dgt.Discipline.Id == item.Discipline.Id &&
|
||||||
|
dgt.Teacher.Id == _teacher.Id);
|
||||||
|
|
||||||
|
if (!alreadyExists)
|
||||||
|
{
|
||||||
|
_disciplineGroupTeachers.Add(new DisciplineGroupTeacher()
|
||||||
|
{
|
||||||
|
Group = group,
|
||||||
|
Teacher = _teacher,
|
||||||
|
Discipline = item.Discipline
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var disc_teach = new DisciplineTeacher() { IdDiscipline = item.Discipline.Id, IdTeacher = lastTeacherId+1 };
|
var disc_teach = new DisciplineTeacher() { IdDiscipline = item.Discipline.Id, IdTeacher = lastTeacherId+1 };
|
||||||
ctx.DisciplineTeachers.Add(disc_teach);
|
ctx.DisciplineTeachers.Add(disc_teach);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var item in _disciplineGroupTeachers)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Discipline: {item.Discipline.Name} Teacher: {item.Teacher.Fio} Group: {item.Group.Id}");
|
||||||
|
}
|
||||||
|
|
||||||
var changes = ctx.SaveChanges();
|
var changes = ctx.SaveChanges();
|
||||||
|
|
||||||
if (changes > 0)
|
if (changes > 0)
|
||||||
@ -77,7 +111,9 @@ public partial class AddTeacher : Window
|
|||||||
|
|
||||||
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
|
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Close(_teachers);
|
Result res = new Result(){Teachers = _teachers, DisciplineGroupTeachers = _disciplineGroupTeachers};
|
||||||
|
|
||||||
|
Close(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DisciplinePresenter()
|
public class DisciplinePresenter()
|
||||||
|
@ -7,6 +7,7 @@ using Avalonia.Controls;
|
|||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using kursovaya.Models;
|
using kursovaya.Models;
|
||||||
|
using kursovaya.ModelsLocal;
|
||||||
|
|
||||||
namespace kursovaya;
|
namespace kursovaya;
|
||||||
|
|
||||||
@ -15,7 +16,9 @@ public partial class AdminWindow : Window
|
|||||||
List<Discipline> Disciplines = new List<Discipline>();
|
List<Discipline> Disciplines = new List<Discipline>();
|
||||||
List<Group> Groups = new List<Group>();
|
List<Group> Groups = new List<Group>();
|
||||||
List<Teacher> Teachers = new List<Teacher>();
|
List<Teacher> Teachers = new List<Teacher>();
|
||||||
ObservableCollection<DisciplineGroupTeacher> DisciplineGroupTeachers = new ObservableCollection<DisciplineGroupTeacher>();
|
|
||||||
|
public List<DisciplineGroupTeacher> dataSourceDisciplineGroupTeachers = new List<DisciplineGroupTeacher>();
|
||||||
|
public ObservableCollection<DisciplineGroupTeacher> DisciplineGroupTeachers = new ObservableCollection<DisciplineGroupTeacher>();
|
||||||
public AdminWindow()
|
public AdminWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -35,38 +38,25 @@ public partial class AdminWindow : Window
|
|||||||
var groups = ctx.Groups.Where(g => ctx.Attestations.Any(at => ctx.Students.Any(s => s.Id == at.IdUser && s.IdGroup == g.Id) && at.IdDiscipline == discipline.Id));
|
var groups = ctx.Groups.Where(g => ctx.Attestations.Any(at => ctx.Students.Any(s => s.Id == at.IdUser && s.IdGroup == g.Id) && at.IdDiscipline == discipline.Id));
|
||||||
foreach (Group group in groups)
|
foreach (Group group in groups)
|
||||||
{
|
{
|
||||||
DisciplineGroupTeachers.Add(new DisciplineGroupTeacher(){Teacher = teacher, Discipline = discipline, Group = group});
|
dataSourceDisciplineGroupTeachers.Add(new DisciplineGroupTeacher(){Teacher = teacher, Discipline = discipline, Group = group});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DisplayAll();
|
||||||
|
|
||||||
MultComboBox.ItemsSource = DisciplineGroupTeachers.Select(dg => dg.NameComboBox).ToList();
|
MultComboBox.ItemsSource = DisciplineGroupTeachers.Select(dg => dg.NameComboBox).ToList();
|
||||||
FlatGrid.ItemsSource = DisciplineGroupTeachers;
|
FlatGrid.ItemsSource = DisciplineGroupTeachers;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DisciplineGroupTeacher()
|
public void DisplayAll()
|
||||||
{
|
{
|
||||||
public Group Group { get; set; }
|
var ctx = new DatabaseContext();
|
||||||
public Discipline Discipline { get; set; }
|
var temp = dataSourceDisciplineGroupTeachers;
|
||||||
public Teacher Teacher { get; set; }
|
DisciplineGroupTeachers.Clear();
|
||||||
public string DisciplineName
|
|
||||||
|
foreach (var item in temp)
|
||||||
{
|
{
|
||||||
get => Discipline.Name;
|
DisciplineGroupTeachers.Add(item);
|
||||||
}
|
|
||||||
public int GroupId
|
|
||||||
{
|
|
||||||
get => Group.Id;
|
|
||||||
}
|
|
||||||
public string TeacherFio
|
|
||||||
{
|
|
||||||
get => Teacher.Fio;
|
|
||||||
}
|
|
||||||
public string NameComboBox
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return $"{Discipline.Name} - {Group.Id} - {Teacher.Fio}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,15 +94,11 @@ public partial class AdminWindow : Window
|
|||||||
|
|
||||||
private async void ButtonCheckTeachers_OnClick(object? sender, RoutedEventArgs e)
|
private async void ButtonCheckTeachers_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// TeachersFromAdminWindow teachersFromAdminWindow = new TeachersFromAdminWindow();
|
|
||||||
// teachersFromAdminWindow.ShowDialog(this);
|
|
||||||
|
|
||||||
TeachersFromAdminWindow teachersFromAdminWindow = new TeachersFromAdminWindow();
|
TeachersFromAdminWindow teachersFromAdminWindow = new TeachersFromAdminWindow();
|
||||||
var result = await teachersFromAdminWindow.ShowDialog<Boolean>(this);
|
var result = await teachersFromAdminWindow.ShowDialog<List<DisciplineGroupTeacher>>(this);
|
||||||
if (result == true)
|
|
||||||
{
|
dataSourceDisciplineGroupTeachers.AddRange(result);
|
||||||
Display();
|
DisplayAll();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonCheckDiscipline_OnClick(object? sender, RoutedEventArgs e)
|
private void ButtonCheckDiscipline_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
30
ModelsLocal/DisciplineGroupTeacher.cs
Normal file
30
ModelsLocal/DisciplineGroupTeacher.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using kursovaya.Models;
|
||||||
|
|
||||||
|
namespace kursovaya.ModelsLocal;
|
||||||
|
|
||||||
|
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 int GroupId
|
||||||
|
{
|
||||||
|
get => Group.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TeacherFio
|
||||||
|
{
|
||||||
|
get => Teacher.Fio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string NameComboBox
|
||||||
|
{
|
||||||
|
get { return $"{Discipline.Name} - {Group.Id} - {Teacher.Fio}"; }
|
||||||
|
}
|
||||||
|
}
|
10
ModelsLocal/Result.cs
Normal file
10
ModelsLocal/Result.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using kursovaya.Models;
|
||||||
|
|
||||||
|
namespace kursovaya.ModelsLocal;
|
||||||
|
|
||||||
|
public class Result()
|
||||||
|
{
|
||||||
|
public List<Teacher> Teachers { get; set; }
|
||||||
|
public List<DisciplineGroupTeacher> DisciplineGroupTeachers { get; set; }
|
||||||
|
}
|
@ -6,6 +6,7 @@ using Avalonia.Controls;
|
|||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using kursovaya.Models;
|
using kursovaya.Models;
|
||||||
|
using kursovaya.ModelsLocal;
|
||||||
|
|
||||||
namespace kursovaya;
|
namespace kursovaya;
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ public partial class TeachersFromAdminWindow : Window
|
|||||||
{
|
{
|
||||||
public List<Teacher> dataSourceTeachers = new List<Teacher>();
|
public List<Teacher> dataSourceTeachers = new List<Teacher>();
|
||||||
public ObservableCollection<Teacher> Teachers = new ObservableCollection<Teacher>();
|
public ObservableCollection<Teacher> Teachers = new ObservableCollection<Teacher>();
|
||||||
List<Teacher> _addedTeachers = new List<Teacher>();
|
Result result = new Result();
|
||||||
public TeachersFromAdminWindow()
|
public TeachersFromAdminWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -27,14 +28,7 @@ public partial class TeachersFromAdminWindow : Window
|
|||||||
|
|
||||||
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
|
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_addedTeachers == null || _addedTeachers.Count == 0)
|
Close(result.DisciplineGroupTeachers);
|
||||||
{
|
|
||||||
Close(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Close(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisplayTeachers()
|
public void DisplayTeachers()
|
||||||
@ -52,12 +46,12 @@ public partial class TeachersFromAdminWindow : Window
|
|||||||
private async void ButtonAddTeacher_OnClick(object? sender, RoutedEventArgs e)
|
private async void ButtonAddTeacher_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
AddTeacher addTeacher = new AddTeacher();
|
AddTeacher addTeacher = new AddTeacher();
|
||||||
_addedTeachers = await addTeacher.ShowDialog<List<Teacher>>(this);
|
result = await addTeacher.ShowDialog<Result>(this);
|
||||||
if (_addedTeachers == null || _addedTeachers.Count == 0)
|
if (result.Teachers == null || result.Teachers.Count == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dataSourceTeachers.AddRange(_addedTeachers);
|
dataSourceTeachers.AddRange(result.Teachers);
|
||||||
DisplayTeachers();
|
DisplayTeachers();
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
|||||||
f0de6e47f368c7d2b430389bae7c7fda5f65514e38af332e1f0fd91696366f73
|
4a653792709c12e18c09bc6f0460d9f61d1fd7d180a73a62ac47c42063efe969
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("kursovaya")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("kursovaya")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c5083481c68ef5cc39a2cfcc445063f2773e3a9f")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d7abb5ffd689ebecb45a3eaa84e87dfd90e6d9f7")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("kursovaya")]
|
[assembly: System.Reflection.AssemblyProductAttribute("kursovaya")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("kursovaya")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("kursovaya")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
63629f52d026f6c617a2e1d2be3f8b814551f6d1d0a2981d0c3782f8ad0ba5ad
|
56b533d6bc40151d11e8da76022af04036771e41ff8ddd0fbff74168ace28e08
|
||||||
|
@ -1 +1 @@
|
|||||||
71f8c7885cc41c61509dddd287b6e947d22d2d15c24d98b288e9f7c66559ec2e
|
c5932addac0a6bc3a167df371d96f37e6eca09a500d93ddafd26cb087e00fdef
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user