From ffb9d2134fbb1b7be6c05ec6ad7159dd069dd3fd Mon Sep 17 00:00:00 2001 From: Dasha06 Date: Thu, 26 Dec 2024 11:03:24 +0300 Subject: [PATCH] done with part of the presence --- Presence.Desktop/App.axaml | 5 +-- Presence.Desktop/Presence.Desktop.csproj | 1 + .../ViewModels/PresenceViewModel.cs | 32 ++++++++++++++---- Presence.Desktop/Views/PresenceView.axaml | 17 +++++----- Presence.Desktop/Views/PresenceView.axaml.cs | 15 ++++++++ .../Debug/net8.0/Presence.Desktop.deps.json | 1 + .../bin/Debug/net8.0/Presence.Desktop.dll | Bin 237056 -> 238592 bytes .../bin/Debug/net8.0/Presence.Desktop.pdb | Bin 23164 -> 23600 bytes Presence.Desktop/bin/Debug/net8.0/data.dll | Bin 41472 -> 41984 bytes Presence.Desktop/bin/Debug/net8.0/data.pdb | Bin 20588 -> 20684 bytes Presence.Desktop/bin/Debug/net8.0/domain.dll | Bin 25088 -> 25088 bytes Presence.Desktop/bin/Debug/net8.0/domain.pdb | Bin 19332 -> 19376 bytes .../net8.0/Avalonia/Presence.Desktop.dll | Bin 237056 -> 238592 bytes .../net8.0/Avalonia/Presence.Desktop.pdb | Bin 23164 -> 23600 bytes .../net8.0/Avalonia/Resources.Inputs.cache | 2 +- .../obj/Debug/net8.0/Avalonia/resources | Bin 183209 -> 183406 bytes .../net8.0/Presence.Desktop.AssemblyInfo.cs | 4 +-- .../Presence.Desktop.AssemblyInfoInputs.cache | 2 +- .../net8.0/Presence.Desktop.assets.cache | Bin 31752 -> 31891 bytes ...nce.Desktop.csproj.AssemblyReference.cache | Bin 22498 -> 22498 bytes .../obj/Debug/net8.0/Presence.Desktop.dll | Bin 208384 -> 209920 bytes .../obj/Debug/net8.0/Presence.Desktop.pdb | Bin 21668 -> 22084 bytes .../obj/Debug/net8.0/ref/Presence.Desktop.dll | Bin 12288 -> 12288 bytes .../refint/Avalonia/Presence.Desktop.dll | Bin 12288 -> 12288 bytes .../Debug/net8.0/refint/Presence.Desktop.dll | Bin 12800 -> 12800 bytes .../Presence.Desktop.csproj.nuget.dgspec.json | 4 +++ Presence.Desktop/obj/project.assets.json | 5 +++ Presence.Desktop/obj/project.nuget.cache | 2 +- .../Debug/net8.0/console_ui.AssemblyInfo.cs | 2 +- .../console_ui.AssemblyInfoInputs.cache | 2 +- .../console_ui.csproj.AssemblyReference.cache | Bin 12214 -> 11349 bytes data/Repository/IPresenceRepository.cs | 2 ++ data/Repository/PresenceRepositoryImpl.cs | 10 ++++++ data/bin/Debug/net8.0/data.dll | Bin 41472 -> 41984 bytes data/bin/Debug/net8.0/data.pdb | Bin 20588 -> 20684 bytes data/obj/Debug/net8.0/data.AssemblyInfo.cs | 4 +-- .../net8.0/data.AssemblyInfoInputs.cache | 2 +- data/obj/Debug/net8.0/data.dll | Bin 41472 -> 41984 bytes data/obj/Debug/net8.0/data.pdb | Bin 20588 -> 20684 bytes data/obj/Debug/net8.0/ref/data.dll | Bin 14848 -> 14848 bytes data/obj/Debug/net8.0/refint/data.dll | Bin 14848 -> 14848 bytes domain/UseCase/PresenceUseCase.cs | 5 +++ domain/bin/Debug/net8.0/data.dll | Bin 41472 -> 41984 bytes domain/bin/Debug/net8.0/data.pdb | Bin 20588 -> 20684 bytes domain/bin/Debug/net8.0/domain.dll | Bin 25088 -> 25088 bytes domain/bin/Debug/net8.0/domain.pdb | Bin 19332 -> 19376 bytes .../obj/Debug/net8.0/domain.AssemblyInfo.cs | 4 +-- .../net8.0/domain.AssemblyInfoInputs.cache | 2 +- .../domain.csproj.AssemblyReference.cache | Bin 8151 -> 8151 bytes domain/obj/Debug/net8.0/domain.dll | Bin 25088 -> 25088 bytes domain/obj/Debug/net8.0/domain.pdb | Bin 19332 -> 19376 bytes domain/obj/Debug/net8.0/ref/domain.dll | Bin 13312 -> 13824 bytes domain/obj/Debug/net8.0/refint/domain.dll | Bin 13312 -> 13824 bytes presence_api/bin/Debug/net8.0/data.dll | Bin 40960 -> 41984 bytes presence_api/bin/Debug/net8.0/data.pdb | Bin 20448 -> 20684 bytes presence_api/bin/Debug/net8.0/domain.dll | Bin 25088 -> 25088 bytes presence_api/bin/Debug/net8.0/domain.pdb | Bin 19156 -> 19376 bytes .../bin/Debug/net8.0/presence_api.dll | Bin 12288 -> 12288 bytes .../bin/Debug/net8.0/presence_api.pdb | Bin 23432 -> 23432 bytes .../Debug/net8.0/presence_api.AssemblyInfo.cs | 2 +- .../presence_api.AssemblyInfoInputs.cache | 2 +- ...resence_api.csproj.AssemblyReference.cache | Bin 5242 -> 5581 bytes .../obj/Debug/net8.0/presence_api.dll | Bin 12288 -> 12288 bytes .../obj/Debug/net8.0/presence_api.pdb | Bin 23432 -> 23432 bytes .../obj/Debug/net8.0/ref/presence_api.dll | Bin 8192 -> 8192 bytes .../obj/Debug/net8.0/refint/presence_api.dll | Bin 8192 -> 8192 bytes ui/obj/Debug/net8.0/ui.AssemblyInfo.cs | 2 +- .../Debug/net8.0/ui.AssemblyInfoInputs.cache | 2 +- .../net8.0/ui.csproj.AssemblyReference.cache | Bin 10602 -> 10602 bytes 69 files changed, 98 insertions(+), 33 deletions(-) diff --git a/Presence.Desktop/App.axaml b/Presence.Desktop/App.axaml index d3f2dbe..fb6e015 100644 --- a/Presence.Desktop/App.axaml +++ b/Presence.Desktop/App.axaml @@ -5,6 +5,7 @@ - - + + + \ No newline at end of file diff --git a/Presence.Desktop/Presence.Desktop.csproj b/Presence.Desktop/Presence.Desktop.csproj index ccd94d0..8e94e3c 100644 --- a/Presence.Desktop/Presence.Desktop.csproj +++ b/Presence.Desktop/Presence.Desktop.csproj @@ -15,6 +15,7 @@ + diff --git a/Presence.Desktop/ViewModels/PresenceViewModel.cs b/Presence.Desktop/ViewModels/PresenceViewModel.cs index c4a8bf8..ce76ecf 100644 --- a/Presence.Desktop/ViewModels/PresenceViewModel.cs +++ b/Presence.Desktop/ViewModels/PresenceViewModel.cs @@ -8,6 +8,7 @@ using ReactiveUI; using System; using System.Collections.ObjectModel; using System.Globalization; +using System.Linq; using System.Reactive; namespace Presence.Desktop.ViewModels @@ -22,6 +23,12 @@ namespace Presence.Desktop.ViewModels public ObservableCollection AttendanceRecords { get; set; } = new(); public ObservableCollection Groups { get; set; } = new(); + private ObservableCollection _selectedItems = new(); + public ObservableCollection SelectedItems + { + get => _selectedItems; + set => this.RaiseAndSetIfChanged(ref _selectedItems, value); + } private GroupPresenter? _selectedGroup; public GroupPresenter? SelectedGroup @@ -46,6 +53,7 @@ namespace Presence.Desktop.ViewModels } public ReactiveCommand NavigateBackCommand { get; } + public ReactiveCommand DeleteSelectedPresenceCommand { get; } public PresenceViewModel(GroupUseCase groupUseCase, PresenceUseCase presenceUseCase) { @@ -55,12 +63,9 @@ namespace Presence.Desktop.ViewModels NavigateBackCommand = ReactiveCommand.Create(() => { }); + DeleteSelectedPresenceCommand = ReactiveCommand.Create(DeleteSelectedItems); - this.WhenAnyValue(vm => vm.SelectedGroup) - .Subscribe(_ => - { - LoadGroups(); - }); + LoadGroups(); } private void LoadGroups() @@ -80,7 +85,7 @@ namespace Presence.Desktop.ViewModels private void FilterAttendanceRecords() { - if (SelectedGroup == null) + if (SelectedGroup == null || SelectedDate == null) { AttendanceRecords.Clear(); return; @@ -106,6 +111,21 @@ namespace Presence.Desktop.ViewModels } }); } + + // Логирование для отладки + Console.WriteLine($"Загружено записей посещаемости: {AttendanceRecords.Count}"); + } + + private void DeleteSelectedItems() + { + if (SelectedItems.Any()) + { + foreach (var item in SelectedItems.ToList()) + { + _presenceUseCase.DeletePresenceByClassNumberAndDateAndUserId(item.ClassNumber, item.Date, item.User.Id); // Удаляем из базы данных + AttendanceRecords.Remove(item); // Удаляем из коллекции + } + } } diff --git a/Presence.Desktop/Views/PresenceView.axaml b/Presence.Desktop/Views/PresenceView.axaml index 7c47916..5da2718 100644 --- a/Presence.Desktop/Views/PresenceView.axaml +++ b/Presence.Desktop/Views/PresenceView.axaml @@ -7,8 +7,8 @@ x:Class="Presence.Desktop.Views.PresenceView" x:DataType="vm:PresenceViewModel"> - - + + @@ -22,17 +22,18 @@ + - + - + - - - - +