diff --git a/Presence.Desktop/ViewModels/PresenceViewModel.cs b/Presence.Desktop/ViewModels/PresenceViewModel.cs index 2c75302..38083b9 100644 --- a/Presence.Desktop/ViewModels/PresenceViewModel.cs +++ b/Presence.Desktop/ViewModels/PresenceViewModel.cs @@ -6,6 +6,7 @@ using ReactiveUI; using System; using System.Collections.ObjectModel; using System.Globalization; +using System.Linq; using System.Reactive; namespace Presence.Desktop.ViewModels @@ -43,7 +44,15 @@ namespace Presence.Desktop.ViewModels } } + private ObservableCollection _selectedItems = new(); + public ObservableCollection SelectedItems + { + get => _selectedItems; + set => this.RaiseAndSetIfChanged(ref _selectedItems, value); + } + public ReactiveCommand NavigateBackCommand { get; } + public ReactiveCommand DeleteSelectedItemsCommand { get; } public PresenceViewModel(IScreen hostScreen, GroupUseCase groupUseCase, UseCaseGeneratePresence presenceUseCase) { @@ -52,6 +61,7 @@ namespace Presence.Desktop.ViewModels HostScreen = hostScreen; NavigateBackCommand = ReactiveCommand.Create(() => { }); + DeleteSelectedItemsCommand = ReactiveCommand.Create(DeleteSelectedItems); LoadGroups(); } @@ -91,6 +101,16 @@ namespace Presence.Desktop.ViewModels _presenceUseCase.UpdateAttendance(presence); } - + private void DeleteSelectedItems() + { + if (SelectedItems.Any()) + { + foreach (var item in SelectedItems.ToList()) + { + _presenceUseCase.DeletePresence(item); // Удаляем из базы данных + AttendanceRecords.Remove(item); // Удаляем из коллекции + } + } + } } } \ No newline at end of file diff --git a/Presence.Desktop/Views/PresenceView.axaml b/Presence.Desktop/Views/PresenceView.axaml index 5980d99..09eb6ad 100644 --- a/Presence.Desktop/Views/PresenceView.axaml +++ b/Presence.Desktop/Views/PresenceView.axaml @@ -23,15 +23,18 @@ - + - - + + +