diff --git a/Apollon.WPF/App.xaml.cs b/Apollon.WPF/App.xaml.cs index 747f7f2..edf62a6 100644 --- a/Apollon.WPF/App.xaml.cs +++ b/Apollon.WPF/App.xaml.cs @@ -1,5 +1,4 @@ using Apollon.Domain.Commands; -using Apollon.Domain.Models; using Apollon.Domain.Queries; using Apollon.EntityFramework; using Apollon.EntityFramework.Commands; @@ -8,19 +7,10 @@ using Apollon.WPF.Services; using Apollon.WPF.Stores; using Apollon.WPF.ViewModels; using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; using System.Windows; namespace Apollon.WPF -{ - /// - /// Interaction logic for App.xaml - /// +{ public partial class App : Application { private readonly NavigationStore _navigationStore; @@ -65,19 +55,13 @@ namespace Apollon.WPF OverviewViewModel overviewViewModel = OverviewViewModel.LoadViewModel( _selectedTournamentStore, - _modalNavigationStore, - _tournamentStore, - _navigationStore, - CreateGroupsNavigationService()); + _modalNavigationStore, + _tournamentStore, + CreateGroupsNavigationService(), + CreateNamelistNavigationService()); - _navigationStore.CurrentViewModel = OverviewViewModel.LoadViewModel( - _selectedTournamentStore, - _modalNavigationStore, - _tournamentStore, - _navigationStore, - CreateGroupsNavigationService()); - - + NavigationService overvoewNavigationService = CreateOverviewNavigationService(); + overvoewNavigationService.Navigate(); MainWindow = new MainWindow() { @@ -91,13 +75,13 @@ namespace Apollon.WPF private NavigationService CreateOverviewNavigationService() { return new NavigationService( - _navigationStore, () => OverviewViewModel.LoadViewModel(_selectedTournamentStore, _modalNavigationStore, _tournamentStore, _navigationStore, CreateGroupsNavigationService())); + _navigationStore, () => OverviewViewModel.LoadViewModel(_selectedTournamentStore, _modalNavigationStore, _tournamentStore, CreateGroupsNavigationService(), CreateNamelistNavigationService())); } private NavigationService CreateGroupsNavigationService() { return new NavigationService( - _navigationStore, () => new GroupsViewModel( _navBarPreparationViewModel, _selectedTournamentStore, _navigationStore, _modalNavigationStore, _tournamentStore, CreateGroupsNavigationService())); + _navigationStore, () => new GroupsViewModel(_navBarPreparationViewModel, _selectedTournamentStore, CreateOverviewNavigationService())); } private NavigationService CreateClassesNavigationService() diff --git a/Apollon.WPF/Commands/AddTournamentCommand.cs b/Apollon.WPF/Commands/AddTournamentCommand.cs index 3e3161a..20bb23d 100644 --- a/Apollon.WPF/Commands/AddTournamentCommand.cs +++ b/Apollon.WPF/Commands/AddTournamentCommand.cs @@ -2,29 +2,22 @@ using Apollon.WPF.Stores; using Apollon.WPF.ViewModels; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; namespace Apollon.WPF.Commands { public class AddTournamentCommand : AsyncCommandBase { - private readonly TournamentsStore _tournamentStore; - private readonly NavigationStore _navigationStore; - private readonly ModalNavigationStore _modalNavigationStore; - private readonly SelectedTournamentsStore _selectedTournamentsStore; + private readonly TournamentsStore _tournamentStore; + private readonly ModalNavigationStore _modalNavigationStore; private AddTournamentViewModel _addTournamentViewModel; - public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore, SelectedTournamentsStore selectedTournamentsStore) + public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore) { _addTournamentViewModel = addTournamentViewModel; _tournamentStore = tournamentStore; - _modalNavigationStore = modalNavigationStore; - _navigationStore = navigationStore; - _selectedTournamentsStore = selectedTournamentsStore; + _modalNavigationStore = modalNavigationStore; } public override async Task ExecuteAsync(object parameter) @@ -51,8 +44,7 @@ namespace Apollon.WPF.Commands { await _tournamentStore.Add(tournament); - _modalNavigationStore.Close(); - //_navigationStore.CurrentViewModel = new GroupsViewModel(_selectedTournamentsStore, _navigationStore, _modalNavigationStore, _tournamentStore); + _modalNavigationStore.Close(); } catch (Exception) diff --git a/Apollon.WPF/Commands/OpenAddTournamentCommand.cs b/Apollon.WPF/Commands/OpenAddTournamentCommand.cs index 84a1701..00dce61 100644 --- a/Apollon.WPF/Commands/OpenAddTournamentCommand.cs +++ b/Apollon.WPF/Commands/OpenAddTournamentCommand.cs @@ -10,22 +10,19 @@ namespace Apollon.WPF.Commands { public class OpenAddTournamentCommand : CommandBase { - private readonly TournamentsStore _tournamentStore; - private readonly SelectedTournamentsStore _selectedTournamentsStore; - private readonly NavigationStore _navigationStore; + private readonly TournamentsStore _tournamentStore; private readonly ModalNavigationStore _modalNavigationStore; - public OpenAddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore, SelectedTournamentsStore selectedTournamentsStore) + public OpenAddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore) { - _tournamentStore = tournamentStore; - _navigationStore = navigationStore; + _tournamentStore = tournamentStore; _modalNavigationStore = modalNavigationStore; - _selectedTournamentsStore = selectedTournamentsStore; + } public override void Execute(object parameter) { - AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_tournamentStore, _modalNavigationStore, _navigationStore, _selectedTournamentsStore); + AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_tournamentStore, _modalNavigationStore); _modalNavigationStore.CurrentViewModel = addTournamentViewModel; } } diff --git a/Apollon.WPF/ViewModels/AddTournametViewModel.cs b/Apollon.WPF/ViewModels/AddTournametViewModel.cs index 1020230..253f83e 100644 --- a/Apollon.WPF/ViewModels/AddTournametViewModel.cs +++ b/Apollon.WPF/ViewModels/AddTournametViewModel.cs @@ -13,9 +13,9 @@ namespace Apollon.WPF.ViewModels { public AddEditDetailsViewModel AddEditDetailsViewModel { get; } - public AddTournamentViewModel(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore,SelectedTournamentsStore selectedTournamentsStore) + public AddTournamentViewModel(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore) { - ICommand submitCommand = new AddTournamentCommand(this, tournamentStore,modalNavigationStore,navigationStore, selectedTournamentsStore); + ICommand submitCommand = new AddTournamentCommand(this, tournamentStore,modalNavigationStore); ICommand cancelCommand = new CloseModalCommand(modalNavigationStore); AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand); } diff --git a/Apollon.WPF/ViewModels/GroupsViewModel.cs b/Apollon.WPF/ViewModels/GroupsViewModel.cs index 22a927b..752c414 100644 --- a/Apollon.WPF/ViewModels/GroupsViewModel.cs +++ b/Apollon.WPF/ViewModels/GroupsViewModel.cs @@ -18,13 +18,13 @@ namespace Apollon.WPF.ViewModels public NavBarPreparationViewModel NavBarPreparationViewModel { get; } public ICommand NavigateOverviewCommand { get; } - public GroupsViewModel(NavBarPreparationViewModel navBarPreparationViewModel, SelectedTournamentsStore selectedTournamentStore, NavigationStore navigationStore, ModalNavigationStore modalNavigationStore, TournamentsStore tournamentsStore, NavigationService groupNavigationService) + public GroupsViewModel(NavBarPreparationViewModel navBarPreparationViewModel, SelectedTournamentsStore selectedTournamentStore, NavigationService overviewNavigationService) { TournamentDetailsViewModel = new TournamentDetailsViewModel(selectedTournamentStore); NavBarPreparationViewModel = navBarPreparationViewModel; - NavigateOverviewCommand = new NavigateCommand(new NavigationService(navigationStore, () => OverviewViewModel.LoadViewModel(selectedTournamentStore, modalNavigationStore, tournamentsStore, navigationStore, groupNavigationService))); + NavigateOverviewCommand = new NavigateCommand(overviewNavigationService); } } } diff --git a/Apollon.WPF/ViewModels/OverviewViewModel.cs b/Apollon.WPF/ViewModels/OverviewViewModel.cs index 5fe8e33..44dff04 100644 --- a/Apollon.WPF/ViewModels/OverviewViewModel.cs +++ b/Apollon.WPF/ViewModels/OverviewViewModel.cs @@ -46,25 +46,24 @@ namespace Apollon.WPF.ViewModels public ICommand NavigateNameListCommand { get; } public OverviewViewModel(TournamentsStore tournamentStore, SelectedTournamentsStore selectedTournamentStore, - ModalNavigationStore modalNavigationStore, NavigationStore navigationStore, NavigationService groupNavigationService) + ModalNavigationStore modalNavigationStore, NavigationService groupNavigationService, NavigationService NameListNavigationService) { OverviewListingViewModel = new OverviewListingViewModel(selectedTournamentStore, modalNavigationStore, tournamentStore); OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore ,groupNavigationService); LoadTournamentsCommand = new LoadTournamentsCommand(this, tournamentStore); - OpenAddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore, navigationStore, selectedTournamentStore); - NavigateNameListCommand = new NavigateCommand(new NavigationService( - navigationStore, () => new NameListViewModel())); + OpenAddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore); + NavigateNameListCommand = new NavigateCommand(NameListNavigationService); } public static OverviewViewModel LoadViewModel(SelectedTournamentsStore selectedTournamentStore, ModalNavigationStore modalNavigationStore, - TournamentsStore tournamentStore, - NavigationStore navigationStore, - NavigationService groupNavigationService) + TournamentsStore tournamentStore, + NavigationService groupNavigationService, + NavigationService NameListNavigationService) { - OverviewViewModel viewModel = new OverviewViewModel(tournamentStore, selectedTournamentStore, modalNavigationStore, navigationStore, groupNavigationService); + OverviewViewModel viewModel = new OverviewViewModel(tournamentStore, selectedTournamentStore, modalNavigationStore,groupNavigationService, NameListNavigationService); viewModel.LoadTournamentsCommand.Execute(null);