From 694b932f24004dca39560e67b53f748ca8d6db23 Mon Sep 17 00:00:00 2001 From: Natlinux81 <97396587+Natlinux81@users.noreply.github.com> Date: Sun, 21 Aug 2022 20:05:39 +0200 Subject: [PATCH] finish delete Modal --- Apollon.WPF/Commands/DeleteTournamentCommand.cs | 8 ++++++-- Apollon.WPF/Commands/OpenWarningDeleteCommand.cs | 12 +++++++++--- .../ViewModels/OverviewListingItemViewModel.cs | 2 +- Apollon.WPF/ViewModels/WarningDeleteViewModel.cs | 10 ++++++++-- Apollon.WPF/Views/WarningDeleteView.xaml | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Apollon.WPF/Commands/DeleteTournamentCommand.cs b/Apollon.WPF/Commands/DeleteTournamentCommand.cs index cf999da..e8e8ada 100644 --- a/Apollon.WPF/Commands/DeleteTournamentCommand.cs +++ b/Apollon.WPF/Commands/DeleteTournamentCommand.cs @@ -13,11 +13,13 @@ namespace Apollon.WPF.Commands { private readonly OverviewListingItemViewModel _overviewListingItemViewModel; private readonly TournamentsStore _tournamentStore; + private readonly ModalNavigationStore _modalNavigationStore; - public DeleteTournamentCommand(OverviewListingItemViewModel overviewListingItemViewModel, TournamentsStore tournamentStore) + public DeleteTournamentCommand(OverviewListingItemViewModel overviewListingItemViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore) { _overviewListingItemViewModel = overviewListingItemViewModel; - _tournamentStore = tournamentStore; + _tournamentStore = tournamentStore; + _modalNavigationStore = modalNavigationStore; } public override async Task ExecuteAsync(object parameter) @@ -27,6 +29,8 @@ namespace Apollon.WPF.Commands try { await _tournamentStore.Delete(tournament.Id); + + _modalNavigationStore.Close(); } catch (Exception) { diff --git a/Apollon.WPF/Commands/OpenWarningDeleteCommand.cs b/Apollon.WPF/Commands/OpenWarningDeleteCommand.cs index 3dfda05..b66980e 100644 --- a/Apollon.WPF/Commands/OpenWarningDeleteCommand.cs +++ b/Apollon.WPF/Commands/OpenWarningDeleteCommand.cs @@ -1,4 +1,5 @@ -using Apollon.WPF.Stores; +using Apollon.Domain.Models; +using Apollon.WPF.Stores; using Apollon.WPF.ViewModels; using System; using System.Collections.Generic; @@ -10,16 +11,21 @@ namespace Apollon.WPF.Commands { public class OpenWarningDeleteCommand : CommandBase { + private readonly OverviewListingItemViewModel _overviewListingItemViewModel; private readonly ModalNavigationStore _modalNavigationStore; + private readonly TournamentsStore _tournamentsStore; - public OpenWarningDeleteCommand(ModalNavigationStore modalNavigationStore) + public OpenWarningDeleteCommand(OverviewListingItemViewModel overviewListingItemViewModel, ModalNavigationStore modalNavigationStore, TournamentsStore tournamentsStore) { + _overviewListingItemViewModel = overviewListingItemViewModel; _modalNavigationStore = modalNavigationStore; + _tournamentsStore = tournamentsStore; } public override void Execute(object parameter) { - WarningDeleteViewModel warningDeleteViewModel = new WarningDeleteViewModel(_modalNavigationStore); + Tournament tournament =_overviewListingItemViewModel.Tournament; + WarningDeleteViewModel warningDeleteViewModel = new WarningDeleteViewModel(_modalNavigationStore,_tournamentsStore,_overviewListingItemViewModel); _modalNavigationStore.CurrentViewModel = warningDeleteViewModel; } } diff --git a/Apollon.WPF/ViewModels/OverviewListingItemViewModel.cs b/Apollon.WPF/ViewModels/OverviewListingItemViewModel.cs index 9780ad4..f40c467 100644 --- a/Apollon.WPF/ViewModels/OverviewListingItemViewModel.cs +++ b/Apollon.WPF/ViewModels/OverviewListingItemViewModel.cs @@ -27,7 +27,7 @@ namespace Apollon.WPF.ViewModels EditCommand = new OpenEditTournamentCommand(this, tournamentStore, modalNavigationStore); //DeleteCommand = new DeleteTournamentCommand(this, tournamentStore); - WarningDeleteCommand = new OpenWarningDeleteCommand(modalNavigationStore); + WarningDeleteCommand = new OpenWarningDeleteCommand(this, modalNavigationStore, tournamentStore); } public void Update(Tournament tournament) diff --git a/Apollon.WPF/ViewModels/WarningDeleteViewModel.cs b/Apollon.WPF/ViewModels/WarningDeleteViewModel.cs index 76c6715..eb61a8a 100644 --- a/Apollon.WPF/ViewModels/WarningDeleteViewModel.cs +++ b/Apollon.WPF/ViewModels/WarningDeleteViewModel.cs @@ -1,16 +1,22 @@ -using Apollon.WPF.Stores; +using Apollon.WPF.Commands; +using Apollon.WPF.Stores; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Input; namespace Apollon.WPF.ViewModels { public class WarningDeleteViewModel : ViewModelBase { - public WarningDeleteViewModel(ModalNavigationStore modalNavigationStore) + public ICommand WarningCloseCommand { get;} + public ICommand DeleteCommand { get; } + public WarningDeleteViewModel(ModalNavigationStore modalNavigationStore,TournamentsStore tournamentsStore, OverviewListingItemViewModel overviewListingItemViewModel) { + WarningCloseCommand = new CloseModalCommand(modalNavigationStore); + DeleteCommand = new DeleteTournamentCommand(overviewListingItemViewModel, tournamentsStore, modalNavigationStore); } } } diff --git a/Apollon.WPF/Views/WarningDeleteView.xaml b/Apollon.WPF/Views/WarningDeleteView.xaml index 5a9ee3a..952610e 100644 --- a/Apollon.WPF/Views/WarningDeleteView.xaml +++ b/Apollon.WPF/Views/WarningDeleteView.xaml @@ -38,7 +38,7 @@