before adding LoadingSpinner
This commit is contained in:
@@ -55,10 +55,10 @@ namespace Apollon.WPF
|
||||
context.Database.Migrate();
|
||||
}
|
||||
|
||||
OverviewViewModel overviewViewModel = new OverviewViewModel(
|
||||
_tournamentStore,
|
||||
OverviewViewModel overviewViewModel = OverviewViewModel.LoadViewModel(
|
||||
_selectedTournamentStore,
|
||||
_modalNavigationStore,
|
||||
_tournamentStore,
|
||||
_navigationStore);
|
||||
|
||||
_navigationStore.CurrentViewModel = new OverviewViewModel(
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace Apollon.WPF.Commands
|
||||
await _tournamentStore.Add(tournament);
|
||||
|
||||
_modalNavigationStore.Close();
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Apollon.WPF.Stores;
|
||||
using Apollon.WPF.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -9,15 +10,19 @@ namespace Apollon.WPF.Commands
|
||||
{
|
||||
public class LoadTournamentsCommand : AsyncCommandBase
|
||||
{
|
||||
private readonly OverviewViewModel _overviewViewModel;
|
||||
private readonly TournamentsStore _tournamentStore;
|
||||
|
||||
public LoadTournamentsCommand(TournamentsStore tournamentStore)
|
||||
public LoadTournamentsCommand(OverviewViewModel overviewViewModel, TournamentsStore tournamentStore)
|
||||
{
|
||||
_overviewViewModel = overviewViewModel;
|
||||
_tournamentStore = tournamentStore;
|
||||
}
|
||||
|
||||
public override async Task ExecuteAsync(object parameter)
|
||||
{
|
||||
_overviewViewModel.IsLoading = true;
|
||||
|
||||
try
|
||||
{
|
||||
await _tournamentStore.Load();
|
||||
@@ -26,6 +31,10 @@ namespace Apollon.WPF.Commands
|
||||
{
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_overviewViewModel.IsLoading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,9 @@ namespace Apollon.WPF.Stores
|
||||
public async Task Add(Tournament tournament)
|
||||
{
|
||||
await _createTournamentCommand.Execute(tournament);
|
||||
|
||||
_tournaments.Add(tournament);
|
||||
|
||||
TournamentAdded?.Invoke(tournament);
|
||||
}
|
||||
|
||||
@@ -59,7 +62,7 @@ namespace Apollon.WPF.Stores
|
||||
|
||||
int currentIndex = _tournaments.FindIndex(y => y.Id == tournament.Id);
|
||||
|
||||
if (currentIndex == -1)
|
||||
if (currentIndex != -1)
|
||||
{
|
||||
_tournaments[currentIndex] = tournament;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ namespace Apollon.WPF.ViewModels
|
||||
public string Location => Tournament.Location;
|
||||
|
||||
public ICommand EditCommand { get; }
|
||||
//public ICommand DeleteCommand { get; }
|
||||
public ICommand WarningDeleteCommand { get; }
|
||||
|
||||
public OverviewListingItemViewModel(Tournament tournament, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
@@ -26,7 +25,6 @@ namespace Apollon.WPF.ViewModels
|
||||
Tournament = tournament;
|
||||
|
||||
EditCommand = new OpenEditTournamentCommand(this, tournamentStore, modalNavigationStore);
|
||||
//DeleteCommand = new DeleteTournamentCommand(this, tournamentStore);
|
||||
WarningDeleteCommand = new OpenWarningDeleteCommand(this, modalNavigationStore, tournamentStore);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace Apollon.WPF.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand LoadTournamentsCommand { get;}
|
||||
|
||||
public OverviewListingViewModel(SelectedTournamentsStore selectedTournamentStore, ModalNavigationStore modalNavigationStore, TournamentsStore tournamentStore)
|
||||
{
|
||||
@@ -42,8 +41,6 @@ namespace Apollon.WPF.ViewModels
|
||||
_modalNavigationStore = modalNavigationStore;
|
||||
_overviewListingItemViewModels = new ObservableCollection<OverviewListingItemViewModel>();
|
||||
|
||||
LoadTournamentsCommand = new LoadTournamentsCommand(tournamentStore);
|
||||
|
||||
_selectedTournamentStore.SelectedTournamentChanged += SelectedTournamentStore_SelectedTournamentChanged;
|
||||
|
||||
_tournamentStore.TournamentLoaded += TournamentStore_TournamentLoaded;
|
||||
@@ -54,15 +51,6 @@ namespace Apollon.WPF.ViewModels
|
||||
_overviewListingItemViewModels.CollectionChanged += OverviewListingItemViewModels_CollectionChanged;
|
||||
}
|
||||
|
||||
public static OverviewListingViewModel LoadViewModel(SelectedTournamentsStore selectedTournamentStore, ModalNavigationStore modalNavigationStore, TournamentsStore tournamentStore)
|
||||
{
|
||||
OverviewListingViewModel viewModel = new OverviewListingViewModel(selectedTournamentStore, modalNavigationStore, tournamentStore);
|
||||
|
||||
viewModel.LoadTournamentsCommand.Execute(null);
|
||||
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
protected override void Dispose()
|
||||
{
|
||||
_selectedTournamentStore.SelectedTournamentChanged += SelectedTournamentStore_SelectedTournamentChanged;
|
||||
|
||||
@@ -15,17 +15,46 @@ namespace Apollon.WPF.ViewModels
|
||||
public OverviewListingViewModel OverviewListingViewModel { get; }
|
||||
public OverviewDetailsViewModel OverviewDetailsViewModel{ get; }
|
||||
|
||||
private bool _isLoading;
|
||||
public bool IsLoading
|
||||
{
|
||||
get
|
||||
{
|
||||
return IsLoading;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isLoading = value;
|
||||
OnPropertyChanged(nameof(IsLoading));
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand AddTournamentCommand { get; }
|
||||
public ICommand LoadTournamentsCommand { get; }
|
||||
public ICommand NavigateNavBarCommand { get; }
|
||||
|
||||
public OverviewViewModel(TournamentsStore tournamentStore, SelectedTournamentsStore selectedTournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore)
|
||||
public OverviewViewModel(TournamentsStore tournamentStore, SelectedTournamentsStore selectedTournamentStore,
|
||||
ModalNavigationStore modalNavigationStore, NavigationStore navigationStore)
|
||||
{
|
||||
OverviewListingViewModel = OverviewListingViewModel.LoadViewModel(selectedTournamentStore, modalNavigationStore, tournamentStore);
|
||||
OverviewListingViewModel = new OverviewListingViewModel(selectedTournamentStore, modalNavigationStore, tournamentStore);
|
||||
OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore);
|
||||
|
||||
LoadTournamentsCommand = new LoadTournamentsCommand(this, tournamentStore);
|
||||
AddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore);
|
||||
NavigateNavBarCommand = new NavigatCommand<NavBarViewModel>(navigationStore, () => new NavBarViewModel(navigationStore));
|
||||
|
||||
}
|
||||
|
||||
public static OverviewViewModel LoadViewModel(SelectedTournamentsStore selectedTournamentStore,
|
||||
ModalNavigationStore modalNavigationStore,
|
||||
TournamentsStore tournamentStore,
|
||||
NavigationStore navigationStore)
|
||||
{
|
||||
OverviewViewModel viewModel = new OverviewViewModel(tournamentStore, selectedTournamentStore, modalNavigationStore, navigationStore);
|
||||
|
||||
viewModel.LoadTournamentsCommand.Execute(null);
|
||||
|
||||
return viewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user