Renavigate
This commit is contained in:
@@ -12,20 +12,16 @@ namespace Apollon.WPF.Commands
|
|||||||
public class AddTournamentCommand : AsyncCommandBase
|
public class AddTournamentCommand : AsyncCommandBase
|
||||||
{
|
{
|
||||||
private readonly TournamentsStore _tournamentStore;
|
private readonly TournamentsStore _tournamentStore;
|
||||||
|
private readonly NavigationStore _navigationStore;
|
||||||
private readonly ModalNavigationStore _modalNavigationStore;
|
private readonly ModalNavigationStore _modalNavigationStore;
|
||||||
private AddTournamentViewModel _addTournamentViewModel;
|
private AddTournamentViewModel _addTournamentViewModel;
|
||||||
|
|
||||||
public AddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore)
|
||||||
{
|
|
||||||
_tournamentStore = tournamentStore;
|
|
||||||
_modalNavigationStore = modalNavigationStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
|
||||||
{
|
{
|
||||||
_addTournamentViewModel = addTournamentViewModel;
|
_addTournamentViewModel = addTournamentViewModel;
|
||||||
_tournamentStore = tournamentStore;
|
_tournamentStore = tournamentStore;
|
||||||
_modalNavigationStore = modalNavigationStore;
|
_modalNavigationStore = modalNavigationStore;
|
||||||
|
_navigationStore = navigationStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task ExecuteAsync(object parameter)
|
public override async Task ExecuteAsync(object parameter)
|
||||||
@@ -50,6 +46,7 @@ namespace Apollon.WPF.Commands
|
|||||||
await _tournamentStore.Add(tournament);
|
await _tournamentStore.Add(tournament);
|
||||||
|
|
||||||
_modalNavigationStore.Close();
|
_modalNavigationStore.Close();
|
||||||
|
_navigationStore.CurrentViewModel = new NavBarViewModel(_navigationStore);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Apollon.WPF.Commands
|
namespace Apollon.WPF.Commands
|
||||||
{
|
{
|
||||||
public class NavigatCommand<TViewModel> : CommandBase
|
public class NavigateCommand<TViewModel> : CommandBase
|
||||||
where TViewModel : ViewModelBase
|
where TViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
private readonly NavigationStore _navigationStore;
|
private readonly NavigationStore _navigationStore;
|
||||||
private readonly Func<TViewModel> _createViewModel;
|
private readonly Func<TViewModel> _createViewModel;
|
||||||
|
|
||||||
public NavigatCommand(NavigationStore navigationStore, Func<TViewModel> createViewModel)
|
public NavigateCommand(NavigationStore navigationStore, Func<TViewModel> createViewModel)
|
||||||
{
|
{
|
||||||
_navigationStore = navigationStore;
|
_navigationStore = navigationStore;
|
||||||
_createViewModel = createViewModel;
|
_createViewModel = createViewModel;
|
||||||
@@ -22,7 +22,6 @@ namespace Apollon.WPF.Commands
|
|||||||
|
|
||||||
public override void Execute(object parameter)
|
public override void Execute(object parameter)
|
||||||
{
|
{
|
||||||
|
|
||||||
_navigationStore.CurrentViewModel = _createViewModel();
|
_navigationStore.CurrentViewModel = _createViewModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,17 +11,19 @@ namespace Apollon.WPF.Commands
|
|||||||
public class OpenAddTournamentCommand : CommandBase
|
public class OpenAddTournamentCommand : CommandBase
|
||||||
{
|
{
|
||||||
private readonly TournamentsStore _tournamentStore;
|
private readonly TournamentsStore _tournamentStore;
|
||||||
|
private readonly NavigationStore _navigationStore;
|
||||||
private readonly ModalNavigationStore _modalNavigationStore;
|
private readonly ModalNavigationStore _modalNavigationStore;
|
||||||
|
|
||||||
public OpenAddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
public OpenAddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore)
|
||||||
{
|
{
|
||||||
_tournamentStore = tournamentStore;
|
_tournamentStore = tournamentStore;
|
||||||
|
_navigationStore = navigationStore;
|
||||||
_modalNavigationStore = modalNavigationStore;
|
_modalNavigationStore = modalNavigationStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Execute(object parameter)
|
public override void Execute(object parameter)
|
||||||
{
|
{
|
||||||
AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_tournamentStore, _modalNavigationStore);
|
AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_tournamentStore, _modalNavigationStore, _navigationStore);
|
||||||
_modalNavigationStore.CurrentViewModel = addTournamentViewModel;
|
_modalNavigationStore.CurrentViewModel = addTournamentViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,6 @@
|
|||||||
<DataTemplate DataType="{x:Type vms:WarningDeleteViewModel}">
|
<DataTemplate DataType="{x:Type vms:WarningDeleteViewModel}">
|
||||||
<views:WarningDeleteView/>
|
<views:WarningDeleteView/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
<DataTemplate DataType="{x:Type vms:NavBarViewModel}">
|
|
||||||
<views:NavBarView Content="{Binding CurrentViewModel}" DataContext="{Binding NavBarViewModel}"/>
|
|
||||||
</DataTemplate>
|
|
||||||
<DataTemplate DataType="{x:Type vms:OverviewViewModel}">
|
<DataTemplate DataType="{x:Type vms:OverviewViewModel}">
|
||||||
<views:OverviewView Content="{Binding CurrentViewModel}" DataContext="{Binding OverviewViewModel}"/>
|
<views:OverviewView Content="{Binding CurrentViewModel}" DataContext="{Binding OverviewViewModel}"/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ namespace Apollon.WPF.ViewModels
|
|||||||
{
|
{
|
||||||
public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
|
public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
|
||||||
|
|
||||||
public AddTournamentViewModel(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
public AddTournamentViewModel(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore)
|
||||||
{
|
{
|
||||||
ICommand submitCommand = new AddTournamentCommand(this, tournamentStore,modalNavigationStore);
|
ICommand submitCommand = new AddTournamentCommand(this, tournamentStore,modalNavigationStore,navigationStore);
|
||||||
ICommand cancelCommand = new CloseModalCommand(modalNavigationStore);
|
ICommand cancelCommand = new CloseModalCommand(modalNavigationStore);
|
||||||
AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand);
|
AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ namespace Apollon.WPF.ViewModels
|
|||||||
OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore);
|
OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore);
|
||||||
|
|
||||||
LoadTournamentsCommand = new LoadTournamentsCommand(this, tournamentStore);
|
LoadTournamentsCommand = new LoadTournamentsCommand(this, tournamentStore);
|
||||||
AddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore);
|
AddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore, navigationStore);
|
||||||
NavigateNavBarCommand = new NavigatCommand<NavBarViewModel>(navigationStore, () => new NavBarViewModel(navigationStore));
|
NavigateNavBarCommand = new NavigateCommand<NavBarViewModel>(navigationStore, () => new NavBarViewModel(navigationStore));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user