Edit Function are available
This commit is contained in:
@@ -11,18 +11,18 @@ namespace Apollon.WPF.Commands
|
||||
{
|
||||
public class AddTournamentCommand : AsyncCommandBase
|
||||
{
|
||||
private readonly TournamentStore _tournamentStore;
|
||||
private readonly TournamentsStore _tournamentStore;
|
||||
private readonly ModalNavigationStore _modalNavigationStore;
|
||||
private AddTournamentViewModel _addTournamentViewModel;
|
||||
|
||||
|
||||
public AddTournamentCommand(TournamentStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
public AddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
{
|
||||
_tournamentStore = tournamentStore;
|
||||
_modalNavigationStore = modalNavigationStore;
|
||||
}
|
||||
|
||||
public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
{
|
||||
_addTournamentViewModel = addTournamentViewModel;
|
||||
_tournamentStore = tournamentStore;
|
||||
@@ -31,15 +31,16 @@ namespace Apollon.WPF.Commands
|
||||
|
||||
public override async Task ExecuteAsync(object parameter)
|
||||
{
|
||||
AddEditDetailsViewModel formViewModel = _addTournamentViewModel.AddEditDetailsViewModel;
|
||||
AddEditDetailsViewModel detailsViewModel = _addTournamentViewModel.AddEditDetailsViewModel;
|
||||
Tournament tournament = new Tournament(
|
||||
formViewModel.Organisation,
|
||||
formViewModel.TournamentName,
|
||||
formViewModel.Competition,
|
||||
formViewModel.StartDate,
|
||||
formViewModel.EndDate,
|
||||
formViewModel.Location,
|
||||
formViewModel.Rounds);
|
||||
Guid.NewGuid(),
|
||||
detailsViewModel.Organisation,
|
||||
detailsViewModel.TournamentName,
|
||||
detailsViewModel.Competition,
|
||||
detailsViewModel.StartDate,
|
||||
detailsViewModel.EndDate,
|
||||
detailsViewModel.Location,
|
||||
detailsViewModel.Rounds);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Apollon.WPF.Stores;
|
||||
using Apollon.WPF.Models;
|
||||
using Apollon.WPF.Stores;
|
||||
using Apollon.WPF.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -9,18 +11,41 @@ namespace Apollon.WPF.Commands
|
||||
{
|
||||
public class EditTournamentCommand : AsyncCommandBase
|
||||
{
|
||||
private readonly EditTournamentViewModel _editTournamentViewModel;
|
||||
private readonly TournamentsStore _tournamentStore;
|
||||
private readonly ModalNavigationStore _modalNavigationStore;
|
||||
|
||||
public EditTournamentCommand(ModalNavigationStore modalNavigationStore)
|
||||
public EditTournamentCommand(EditTournamentViewModel editTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
{
|
||||
_editTournamentViewModel = editTournamentViewModel;
|
||||
_tournamentStore = tournamentStore;
|
||||
_modalNavigationStore = modalNavigationStore;
|
||||
}
|
||||
|
||||
public override async Task ExecuteAsync(object parameter)
|
||||
{
|
||||
// Edit Tournament to Database
|
||||
AddEditDetailsViewModel detailsViewModel = _editTournamentViewModel.AddEditDetailsViewModel;
|
||||
Tournament tournament = new Tournament(
|
||||
_editTournamentViewModel.TournamentId,
|
||||
detailsViewModel.Organisation,
|
||||
detailsViewModel.TournamentName,
|
||||
detailsViewModel.Competition,
|
||||
detailsViewModel.StartDate,
|
||||
detailsViewModel.EndDate,
|
||||
detailsViewModel.Location,
|
||||
detailsViewModel.Rounds);
|
||||
|
||||
_modalNavigationStore.Close();
|
||||
try
|
||||
{
|
||||
await _tournamentStore.Update(tournament);
|
||||
|
||||
_modalNavigationStore.Close();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ namespace Apollon.WPF.Commands
|
||||
{
|
||||
public class OpenAddTournamentCommand : CommandBase
|
||||
{
|
||||
private readonly TournamentStore _tournamentStore;
|
||||
private readonly TournamentsStore _tournamentStore;
|
||||
private readonly ModalNavigationStore _modalNavigationStore;
|
||||
|
||||
public OpenAddTournamentCommand(TournamentStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
public OpenAddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
{
|
||||
_tournamentStore = tournamentStore;
|
||||
_modalNavigationStore = modalNavigationStore;
|
||||
|
||||
@@ -11,18 +11,22 @@ namespace Apollon.WPF.Commands
|
||||
{
|
||||
public class OpenEditTournamentCommand : CommandBase
|
||||
{
|
||||
private readonly ModalNavigationStore _modalNavigationStore;
|
||||
|
||||
private readonly ModalNavigationStore _modalNavigationStore;
|
||||
private readonly OverviewListingItemViewModel _overviewListingItemViewModel;
|
||||
private readonly TournamentsStore _tournamentStore;
|
||||
|
||||
public OpenEditTournamentCommand(ModalNavigationStore modalNavigationStore)
|
||||
public OpenEditTournamentCommand(OverviewListingItemViewModel overviewListingItemViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
{
|
||||
_overviewListingItemViewModel = overviewListingItemViewModel;
|
||||
_tournamentStore = tournamentStore;
|
||||
_modalNavigationStore = modalNavigationStore;
|
||||
|
||||
}
|
||||
|
||||
public override void Execute(object parameter)
|
||||
{
|
||||
EditTournamentViewModel editTournamentViewModel = new EditTournamentViewModel(_modalNavigationStore);
|
||||
Tournament tournament = _overviewListingItemViewModel.Tournament;
|
||||
|
||||
EditTournamentViewModel editTournamentViewModel = new EditTournamentViewModel(_modalNavigationStore, _tournamentStore, tournament);
|
||||
_modalNavigationStore.CurrentViewModel = editTournamentViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user