submit Add and Edit Command
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Apollon.WPF
|
|||||||
{
|
{
|
||||||
private readonly ModalNavigationStore _modalNavigationStore;
|
private readonly ModalNavigationStore _modalNavigationStore;
|
||||||
private readonly SelectedTournamentStore _selectedTournamentStore;
|
private readonly SelectedTournamentStore _selectedTournamentStore;
|
||||||
private readonly Tournament _tournament;
|
//private readonly Tournament _tournament;
|
||||||
|
|
||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
@@ -27,7 +27,7 @@ namespace Apollon.WPF
|
|||||||
}
|
}
|
||||||
protected override void OnStartup(StartupEventArgs e)
|
protected override void OnStartup(StartupEventArgs e)
|
||||||
{
|
{
|
||||||
OverviewViewModel overviewViewModel = new OverviewViewModel(_selectedTournamentStore, _modalNavigationStore, _tournament);
|
OverviewViewModel overviewViewModel = new OverviewViewModel(_selectedTournamentStore, _modalNavigationStore);
|
||||||
|
|
||||||
MainWindow = new MainWindow()
|
MainWindow = new MainWindow()
|
||||||
{
|
{
|
||||||
|
|||||||
26
Apollon.WPF/Commands/AddTournamentCommand.cs
Normal file
26
Apollon.WPF/Commands/AddTournamentCommand.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Apollon.WPF.Stores;
|
||||||
|
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 ModalNavigationStore _modalNavigationStore;
|
||||||
|
|
||||||
|
public AddTournamentCommand(ModalNavigationStore modalNavigationStore)
|
||||||
|
{
|
||||||
|
_modalNavigationStore = modalNavigationStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task ExecuteAsync(object parameter)
|
||||||
|
{
|
||||||
|
// Add Tournament to Database
|
||||||
|
|
||||||
|
_modalNavigationStore.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
23
Apollon.WPF/Commands/AsyncCommandBase.cs
Normal file
23
Apollon.WPF/Commands/AsyncCommandBase.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Apollon.WPF.Commands
|
||||||
|
{
|
||||||
|
public abstract class AsyncCommandBase : CommandBase
|
||||||
|
{
|
||||||
|
public override async void Execute(object parameter)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ExecuteAsync(parameter);
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Task ExecuteAsync(object parameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
26
Apollon.WPF/Commands/EditTournamentCommand.cs
Normal file
26
Apollon.WPF/Commands/EditTournamentCommand.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Apollon.WPF.Stores;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Apollon.WPF.Commands
|
||||||
|
{
|
||||||
|
public class EditTournamentCommand : AsyncCommandBase
|
||||||
|
{
|
||||||
|
private readonly ModalNavigationStore _modalNavigationStore;
|
||||||
|
|
||||||
|
public EditTournamentCommand(ModalNavigationStore modalNavigationStore)
|
||||||
|
{
|
||||||
|
_modalNavigationStore = modalNavigationStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task ExecuteAsync(object parameter)
|
||||||
|
{
|
||||||
|
// Edit Tournament to Database
|
||||||
|
|
||||||
|
_modalNavigationStore.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,17 +12,15 @@ namespace Apollon.WPF.Commands
|
|||||||
public class OpenEditTournamentCommand : CommandBase
|
public class OpenEditTournamentCommand : CommandBase
|
||||||
{
|
{
|
||||||
private readonly ModalNavigationStore _modalNavigationStore;
|
private readonly ModalNavigationStore _modalNavigationStore;
|
||||||
private readonly Tournament _tournament;
|
|
||||||
|
|
||||||
public OpenEditTournamentCommand(ModalNavigationStore modalNavigationStore, Tournament tournament)
|
public OpenEditTournamentCommand(ModalNavigationStore modalNavigationStore)
|
||||||
{
|
{
|
||||||
_modalNavigationStore = modalNavigationStore;
|
_modalNavigationStore = modalNavigationStore;
|
||||||
_tournament = tournament;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Execute(object parameter)
|
public override void Execute(object parameter)
|
||||||
{
|
{
|
||||||
EditTournamentViewModel editTournamentViewModel = new EditTournamentViewModel(_tournament,_modalNavigationStore);
|
EditTournamentViewModel editTournamentViewModel = new EditTournamentViewModel(_modalNavigationStore);
|
||||||
_modalNavigationStore.CurrentViewModel = editTournamentViewModel;
|
_modalNavigationStore.CurrentViewModel = editTournamentViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ namespace Apollon.WPF.ViewModels
|
|||||||
|
|
||||||
public AddTournamentViewModel(ModalNavigationStore modalNavigationStore)
|
public AddTournamentViewModel(ModalNavigationStore modalNavigationStore)
|
||||||
{
|
{
|
||||||
|
ICommand submitCommand = new AddTournamentCommand(modalNavigationStore);
|
||||||
ICommand cancelCommand = new CloseModalCommand(modalNavigationStore);
|
ICommand cancelCommand = new CloseModalCommand(modalNavigationStore);
|
||||||
AddEditDetailsViewModel = new AddEditDetailsViewModel(null, cancelCommand);
|
AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,18 +14,19 @@ namespace Apollon.WPF.ViewModels
|
|||||||
{
|
{
|
||||||
public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
|
public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
|
||||||
|
|
||||||
public EditTournamentViewModel(Tournament tournament, ModalNavigationStore modalNavigationStore)
|
public EditTournamentViewModel(ModalNavigationStore modalNavigationStore)
|
||||||
{
|
{
|
||||||
|
ICommand submitCommand = new EditTournamentCommand(modalNavigationStore);
|
||||||
ICommand cancelCommand = new CloseModalCommand(modalNavigationStore);
|
ICommand cancelCommand = new CloseModalCommand(modalNavigationStore);
|
||||||
AddEditDetailsViewModel = new AddEditDetailsViewModel(null, cancelCommand)
|
AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand )
|
||||||
{
|
{
|
||||||
Organisation = tournament.Organisation,
|
//Organisation = tournament.Organisation,
|
||||||
Tournamentname = tournament.Tournamentname,
|
//Tournamentname = tournament.Tournamentname,
|
||||||
Category = tournament.Category,
|
//Category = tournament.Category,
|
||||||
Startdate = tournament.Startdate,
|
//Startdate = tournament.Startdate,
|
||||||
Enddate = tournament.Enddate,
|
//Enddate = tournament.Enddate,
|
||||||
Location = tournament.Location,
|
//Location = tournament.Location,
|
||||||
Rounds = tournament.Rounds,
|
//Rounds = tournament.Rounds,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ namespace Apollon.WPF.ViewModels
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public OverviewViewModel(SelectedTournamentStore selectedTournamentStore, ModalNavigationStore modalNavigationStore, Tournament tournament)
|
public OverviewViewModel(SelectedTournamentStore selectedTournamentStore, ModalNavigationStore modalNavigationStore)
|
||||||
{
|
{
|
||||||
OverviewListingViewModel = new OverviewListingViewModel(selectedTournamentStore, modalNavigationStore);
|
OverviewListingViewModel = new OverviewListingViewModel(selectedTournamentStore, modalNavigationStore);
|
||||||
OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore);
|
OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore);
|
||||||
|
|
||||||
AddTournamentCommand = new OpenAddTournamentCommand(modalNavigationStore);
|
AddTournamentCommand = new OpenAddTournamentCommand(modalNavigationStore);
|
||||||
EditTournamentCommand = new OpenEditTournamentCommand(modalNavigationStore, tournament);
|
EditTournamentCommand = new OpenEditTournamentCommand(modalNavigationStore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user