Finish LoadingSpinner
This commit is contained in:
@@ -13,8 +13,7 @@ namespace Apollon.WPF.Commands
|
||||
{
|
||||
private readonly TournamentsStore _tournamentStore;
|
||||
private readonly ModalNavigationStore _modalNavigationStore;
|
||||
private AddTournamentViewModel _addTournamentViewModel;
|
||||
|
||||
private AddTournamentViewModel _addTournamentViewModel;
|
||||
|
||||
public AddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
{
|
||||
@@ -32,6 +31,9 @@ namespace Apollon.WPF.Commands
|
||||
public override async Task ExecuteAsync(object parameter)
|
||||
{
|
||||
AddEditDetailsViewModel detailsViewModel = _addTournamentViewModel.AddEditDetailsViewModel;
|
||||
|
||||
detailsViewModel.IsSubmitting = true;
|
||||
|
||||
Tournament tournament = new Tournament(
|
||||
Guid.NewGuid(),
|
||||
detailsViewModel.Organisation,
|
||||
@@ -51,9 +53,12 @@ namespace Apollon.WPF.Commands
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
detailsViewModel.IsSubmitting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,35 @@ namespace Apollon.WPF.Commands
|
||||
{
|
||||
public abstract class AsyncCommandBase : CommandBase
|
||||
{
|
||||
private bool _isExecuring;
|
||||
public bool IsExecuting
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isExecuring;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isExecuring = value;
|
||||
OnCanExecutedChanged();
|
||||
}
|
||||
}
|
||||
public override bool CanExecute(object parameter)
|
||||
{
|
||||
return !IsExecuting && base.CanExecute(parameter);
|
||||
}
|
||||
public override async void Execute(object parameter)
|
||||
{
|
||||
IsExecuting = true;
|
||||
try
|
||||
{
|
||||
await ExecuteAsync(parameter);
|
||||
}
|
||||
catch (Exception) { }
|
||||
catch (Exception) { }
|
||||
finally
|
||||
{
|
||||
IsExecuting = false;
|
||||
}
|
||||
}
|
||||
public abstract Task ExecuteAsync(object parameter);
|
||||
}
|
||||
|
||||
@@ -10,20 +10,29 @@ using System.Threading.Tasks;
|
||||
namespace Apollon.WPF.Commands
|
||||
{
|
||||
public class DeleteTournamentCommand : AsyncCommandBase
|
||||
{
|
||||
{
|
||||
private readonly OverviewListingItemViewModel _overviewListingItemViewModel;
|
||||
private readonly TournamentsStore _tournamentStore;
|
||||
private readonly ModalNavigationStore _modalNavigationStore;
|
||||
private readonly WarningDeleteViewModel _warningDeleteViewModel;
|
||||
|
||||
public DeleteTournamentCommand(OverviewListingItemViewModel overviewListingItemViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
public DeleteTournamentCommand(WarningDeleteViewModel warningDeleteViewModel, OverviewListingItemViewModel overviewListingItemViewModel, TournamentsStore tournamentsStore, ModalNavigationStore modalNavigationStore)
|
||||
{
|
||||
_warningDeleteViewModel = warningDeleteViewModel;
|
||||
_overviewListingItemViewModel = overviewListingItemViewModel;
|
||||
_tournamentStore = tournamentStore;
|
||||
_tournamentStore = tournamentsStore;
|
||||
_modalNavigationStore = modalNavigationStore;
|
||||
}
|
||||
|
||||
|
||||
public OverviewListingItemViewModel OverviewListingItemViewModel { get; }
|
||||
public TournamentsStore TournamentsStore { get; }
|
||||
public ModalNavigationStore ModalNavigationStore { get; }
|
||||
public WarningDeleteViewModel WarningDeleteViewModel { get; }
|
||||
|
||||
public override async Task ExecuteAsync(object parameter)
|
||||
{
|
||||
_warningDeleteViewModel.IsDeleting = true;
|
||||
|
||||
Tournament tournament = _overviewListingItemViewModel.Tournament;
|
||||
|
||||
try
|
||||
@@ -35,7 +44,12 @@ namespace Apollon.WPF.Commands
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_warningDeleteViewModel.IsDeleting = false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ namespace Apollon.WPF.Commands
|
||||
public override async Task ExecuteAsync(object parameter)
|
||||
{
|
||||
AddEditDetailsViewModel detailsViewModel = _editTournamentViewModel.AddEditDetailsViewModel;
|
||||
|
||||
detailsViewModel.IsSubmitting = true;
|
||||
|
||||
Tournament tournament = new Tournament(
|
||||
_editTournamentViewModel.TournamentId,
|
||||
detailsViewModel.Organisation,
|
||||
@@ -46,6 +49,10 @@ namespace Apollon.WPF.Commands
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
detailsViewModel.IsSubmitting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
||||
namespace Apollon.WPF.Commands
|
||||
{
|
||||
public class OpenWarningDeleteCommand : CommandBase
|
||||
{
|
||||
{
|
||||
private readonly OverviewListingItemViewModel _overviewListingItemViewModel;
|
||||
private readonly ModalNavigationStore _modalNavigationStore;
|
||||
private readonly TournamentsStore _tournamentsStore;
|
||||
@@ -24,7 +24,6 @@ namespace Apollon.WPF.Commands
|
||||
|
||||
public override void Execute(object parameter)
|
||||
{
|
||||
Tournament tournament =_overviewListingItemViewModel.Tournament;
|
||||
WarningDeleteViewModel warningDeleteViewModel = new WarningDeleteViewModel(_modalNavigationStore,_tournamentsStore,_overviewListingItemViewModel);
|
||||
_modalNavigationStore.CurrentViewModel = warningDeleteViewModel;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user