From 080624ca76d45249d8c4b69668a4f1b945d2e0b4 Mon Sep 17 00:00:00 2001 From: -SSS- Date: Wed, 4 Dec 2024 21:00:36 +0300 Subject: [PATCH] init commit --- .../ViewModels/MainWindowViewModel.cs | 89 +++- Presence.Desktop/Views/MainWindow.axaml | 66 +-- .../Debug/net8.0/Presence.Desktop.deps.json | 10 +- .../bin/Debug/net8.0/Presence.Desktop.dll | Bin 207360 -> 212992 bytes .../bin/Debug/net8.0/Presence.Desktop.exe | Bin 143360 -> 139264 bytes .../bin/Debug/net8.0/Presence.Desktop.pdb | Bin 17472 -> 18340 bytes Presence.Desktop/bin/Debug/net8.0/data.dll | Bin 31232 -> 32768 bytes Presence.Desktop/bin/Debug/net8.0/data.pdb | Bin 19088 -> 19512 bytes Presence.Desktop/bin/Debug/net8.0/domain.dll | Bin 19968 -> 20480 bytes Presence.Desktop/bin/Debug/net8.0/domain.pdb | Bin 17656 -> 17900 bytes .../net8.0/Avalonia/Presence.Desktop.dll | Bin 207360 -> 212992 bytes .../net8.0/Avalonia/Presence.Desktop.pdb | Bin 17472 -> 18340 bytes .../net8.0/Avalonia/Resources.Inputs.cache | 2 +- .../obj/Debug/net8.0/Avalonia/references | 442 +++++++++--------- .../obj/Debug/net8.0/Avalonia/resources | Bin 179199 -> 180118 bytes .../net8.0/Presence.Desktop.AssemblyInfo.cs | 2 +- .../Presence.Desktop.AssemblyInfoInputs.cache | 2 +- ....GeneratedMSBuildEditorConfig.editorconfig | 6 +- .../net8.0/Presence.Desktop.assets.cache | Bin 39158 -> 37300 bytes ...nce.Desktop.csproj.AssemblyReference.cache | Bin 33346 -> 32296 bytes ...nce.Desktop.csproj.CoreCompileInputs.cache | 2 +- .../obj/Debug/net8.0/Presence.Desktop.dll | Bin 0 -> 195584 bytes .../Presence.Desktop.genruntimeconfig.cache | 2 +- .../obj/Debug/net8.0/Presence.Desktop.pdb | Bin 0 -> 17624 bytes Presence.Desktop/obj/Debug/net8.0/apphost.exe | Bin 143360 -> 139264 bytes .../obj/Debug/net8.0/ref/Presence.Desktop.dll | Bin 8192 -> 8704 bytes .../refint/Avalonia/Presence.Desktop.dll | Bin 8192 -> 8704 bytes .../Debug/net8.0/refint/Presence.Desktop.dll | Bin 0 -> 9216 bytes .../Presence.Desktop.csproj.nuget.dgspec.json | 59 +-- .../obj/Presence.Desktop.csproj.nuget.g.props | 10 +- Presence.Desktop/obj/project.assets.json | 23 +- Presence.Desktop/obj/project.nuget.cache | 120 ++--- console_ui/obj/Debug/net8.0/apphost.exe | Bin 142848 -> 138752 bytes .../Debug/net8.0/console_ui.AssemblyInfo.cs | 2 +- .../console_ui.AssemblyInfoInputs.cache | 2 +- ....GeneratedMSBuildEditorConfig.editorconfig | 2 +- .../obj/Debug/net8.0/console_ui.assets.cache | Bin 15046 -> 14374 bytes .../console_ui.csproj.AssemblyReference.cache | Bin 14468 -> 14013 bytes .../obj/console_ui.csproj.nuget.dgspec.json | 82 ++-- .../obj/console_ui.csproj.nuget.g.props | 6 +- console_ui/obj/project.assets.json | 27 +- console_ui/obj/project.nuget.cache | 50 +- data/Repository/IGroupRepository.cs | 5 +- data/Repository/SQLGroupRepositoryImpl.cs | 45 ++ data/bin/Debug/net8.0/data.dll | Bin 31232 -> 32768 bytes data/bin/Debug/net8.0/data.pdb | Bin 19088 -> 19512 bytes data/obj/Debug/net8.0/data.AssemblyInfo.cs | 2 +- .../net8.0/data.AssemblyInfoInputs.cache | 2 +- ....GeneratedMSBuildEditorConfig.editorconfig | 2 +- data/obj/Debug/net8.0/data.assets.cache | Bin 37208 -> 36025 bytes .../data.csproj.AssemblyReference.cache | Bin 9396 -> 9140 bytes .../data.csproj.CoreCompileInputs.cache | 2 +- data/obj/Debug/net8.0/data.dll | Bin 31232 -> 32768 bytes .../Debug/net8.0/data.genruntimeconfig.cache | 2 +- data/obj/Debug/net8.0/data.pdb | Bin 19088 -> 19512 bytes data/obj/Debug/net8.0/ref/data.dll | Bin 14336 -> 14336 bytes data/obj/Debug/net8.0/refint/data.dll | Bin 14336 -> 14336 bytes data/obj/data.csproj.nuget.dgspec.json | 17 +- data/obj/data.csproj.nuget.g.props | 8 +- data/obj/project.assets.json | 15 +- data/obj/project.nuget.cache | 80 ++-- domain/UseCase/GroupUseCase.cs | 30 ++ domain/bin/Debug/net8.0/data.dll | Bin 31232 -> 32768 bytes domain/bin/Debug/net8.0/data.pdb | Bin 19088 -> 19512 bytes domain/bin/Debug/net8.0/domain.deps.json | 5 +- domain/bin/Debug/net8.0/domain.dll | Bin 19968 -> 20480 bytes domain/bin/Debug/net8.0/domain.pdb | Bin 17656 -> 17900 bytes .../obj/Debug/net8.0/domain.AssemblyInfo.cs | 2 +- .../net8.0/domain.AssemblyInfoInputs.cache | 2 +- ....GeneratedMSBuildEditorConfig.editorconfig | 2 +- domain/obj/Debug/net8.0/domain.assets.cache | Bin 14690 -> 14036 bytes .../domain.csproj.AssemblyReference.cache | Bin 14589 -> 14170 bytes .../domain.csproj.CoreCompileInputs.cache | 2 +- domain/obj/Debug/net8.0/domain.dll | Bin 19968 -> 20480 bytes domain/obj/Debug/net8.0/domain.pdb | Bin 17656 -> 17900 bytes domain/obj/Debug/net8.0/ref/domain.dll | Bin 9728 -> 10240 bytes domain/obj/Debug/net8.0/refint/domain.dll | Bin 9728 -> 10240 bytes domain/obj/domain.csproj.nuget.dgspec.json | 36 +- domain/obj/domain.csproj.nuget.g.props | 6 +- domain/obj/project.assets.json | 19 +- domain/obj/project.nuget.cache | 50 +- presence_api/obj/Debug/net8.0/apphost.exe | Bin 142848 -> 138752 bytes .../Debug/net8.0/presence_api.AssemblyInfo.cs | 2 +- .../presence_api.AssemblyInfoInputs.cache | 2 +- ....GeneratedMSBuildEditorConfig.editorconfig | 4 +- .../Debug/net8.0/presence_api.assets.cache | Bin 18611 -> 17777 bytes ...resence_api.csproj.AssemblyReference.cache | Bin 14600 -> 14143 bytes .../obj/presence_api.csproj.nuget.dgspec.json | 55 +-- .../obj/presence_api.csproj.nuget.g.props | 8 +- presence_api/obj/project.assets.json | 19 +- presence_api/obj/project.nuget.cache | 64 +-- ui/obj/Debug/net8.0/ui.AssemblyInfo.cs | 2 +- .../Debug/net8.0/ui.AssemblyInfoInputs.cache | 2 +- ....GeneratedMSBuildEditorConfig.editorconfig | 2 +- ui/obj/Debug/net8.0/ui.assets.cache | Bin 14558 -> 13913 bytes .../net8.0/ui.csproj.AssemblyReference.cache | Bin 14173 -> 13736 bytes ui/obj/project.assets.json | 19 +- ui/obj/project.nuget.cache | 50 +- ui/obj/ui.csproj.nuget.dgspec.json | 55 +-- ui/obj/ui.csproj.nuget.g.props | 6 +- 100 files changed, 916 insertions(+), 714 deletions(-) create mode 100644 Presence.Desktop/obj/Debug/net8.0/Presence.Desktop.dll create mode 100644 Presence.Desktop/obj/Debug/net8.0/Presence.Desktop.pdb create mode 100644 Presence.Desktop/obj/Debug/net8.0/refint/Presence.Desktop.dll diff --git a/Presence.Desktop/ViewModels/MainWindowViewModel.cs b/Presence.Desktop/ViewModels/MainWindowViewModel.cs index 4cbb742..a759353 100644 --- a/Presence.Desktop/ViewModels/MainWindowViewModel.cs +++ b/Presence.Desktop/ViewModels/MainWindowViewModel.cs @@ -1,4 +1,5 @@ using DocumentFormat.OpenXml.Bibliography; +using domain.Models; using domain.UseCase; using ReactiveUI; using System; @@ -6,13 +7,13 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Reactive.Linq; +using System.Windows.Input; namespace Presence.Desktop.ViewModels { public class MainWindowViewModel : ViewModelBase { private readonly GroupUseCase _groupUseCase; - private List groupPresentersDataSource = new List(); private ObservableCollection _groups; public ObservableCollection Groups => _groups; @@ -25,9 +26,22 @@ namespace Presence.Desktop.ViewModels private GroupPresenter? _selectedGroupItem; - public ObservableCollection Users { get => _users; } + public ObservableCollection Users { get => _users; } private ObservableCollection _users; + // Список опций сортировки + public List SortOptions { get; } = new List { "По фамилии", "По убыванию" }; + + private string _selectedSortOption; + public string SelectedSortOption + { + get => _selectedSortOption; + set => this.RaiseAndSetIfChanged(ref _selectedSortOption, value); + } + + public ICommand RemoveAllStudentsCommand { get; } + public ICommand AddStudentCommand { get; } + public MainWindowViewModel(GroupUseCase groupUseCase) { _groupUseCase = groupUseCase; @@ -52,6 +66,13 @@ namespace Presence.Desktop.ViewModels this.WhenAnyValue(vm => vm.SelectedGroupItem) .Subscribe(vm => SetUsers()); + + // Обработчик изменения сортировки + this.WhenAnyValue(vm => vm.SelectedSortOption) + .Subscribe(_ => SortUsers()); + + RemoveAllStudentsCommand = ReactiveCommand.Create(RemoveAllStudents); + AddStudentCommand = ReactiveCommand.Create(AddStudent); } private void SetUsers() @@ -63,6 +84,70 @@ namespace Presence.Desktop.ViewModels { Users.Add(item); } + + // Сортировка при изменении группы + SortUsers(); + } + + private void SortUsers() + { + if (SelectedGroupItem?.users == null) return; + + var sortedUsers = SelectedGroupItem.users.ToList(); + + switch (SelectedSortOption) + { + case "По фамилии": + sortedUsers = sortedUsers.OrderBy(u => u.Name).ToList(); + break; + case "По убыванию": + sortedUsers = sortedUsers.OrderByDescending(u => u.Name).ToList(); + break; + } + + Users.Clear(); + foreach (var item in sortedUsers) + { + Users.Add(item); + } + } + + private void RemoveAllStudents() + { + if (SelectedGroupItem == null) return; + + // Удаляем всех студентов через UseCase + _groupUseCase.RemoveAllStudentsFromGroup(SelectedGroupItem.Id); + + // Создаем новый список пользователей (пустой) + SelectedGroupItem.users = new List(); // Перезаписываем users новым пустым списком + SetUsers(); // Обновляем отображение + } + + private void AddStudent() + { + if (SelectedGroupItem == null) return; + + var newStudent = new UserPresenter + { + Name = "Новый студент", + Guid = Guid.NewGuid(), + Group = SelectedGroupItem + }; + + // Добавляем студента в базу данных через UseCase + _groupUseCase.AddStudentToGroup(SelectedGroupItem.Id, new User + { + Guid = newStudent.Guid, + FIO = newStudent.Name + }); + + // Создаем новый список пользователей, добавляем нового студента и присваиваем его + var updatedUsers = SelectedGroupItem.users?.ToList() ?? new List(); // Создаем новый список из существующих пользователей или пустой + updatedUsers.Add(newStudent); // Добавляем нового студента + + SelectedGroupItem.users = updatedUsers; // Перезаписываем users новым списком с добавленным студентом + SetUsers(); // Обновляем отображение } } } diff --git a/Presence.Desktop/Views/MainWindow.axaml b/Presence.Desktop/Views/MainWindow.axaml index 47ca776..20b5874 100644 --- a/Presence.Desktop/Views/MainWindow.axaml +++ b/Presence.Desktop/Views/MainWindow.axaml @@ -9,40 +9,48 @@ Title="Presence.Desktop" x:DataType="vm:MainWindowViewModel"> - - - - - - - - - - - - + + + + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +