clean up AddCommand EditCommand

This commit is contained in:
Natlinux81
2022-08-15 15:17:05 +02:00
parent a694685181
commit 7c5551d619
9 changed files with 44 additions and 15 deletions

View File

@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace Apollon.WPF.Commands
{
internal class OpenAddTournamentCommand : CommandBase
public class OpenAddTournamentCommand : CommandBase
{
private readonly ModalNavigationStore _modalNavigationStore;
@@ -19,8 +19,8 @@ namespace Apollon.WPF.Commands
public override void Execute(object parameter)
{
AddTournametViewModel addTournametViewModel = new AddTournametViewModel(_modalNavigationStore);
_modalNavigationStore.CurrentViewModel = addTournametViewModel;
AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_modalNavigationStore);
_modalNavigationStore.CurrentViewModel = addTournamentViewModel;
}
}
}

View File

@@ -0,0 +1,26 @@
using Apollon.WPF.Stores;
using Apollon.WPF.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Apollon.WPF.Commands
{
public class OpenEditTournamentCommand : CommandBase
{
private readonly ModalNavigationStore _modalNavigationStore;
public OpenEditTournamentCommand(ModalNavigationStore modalNavigationStore)
{
_modalNavigationStore = modalNavigationStore;
}
public override void Execute(object parameter)
{
EditTournamentViewModel editTournamentViewModel = new EditTournamentViewModel(_modalNavigationStore);
_modalNavigationStore.CurrentViewModel = editTournamentViewModel;
}
}
}

View File

@@ -17,7 +17,7 @@
WindowStyle="None"
ResizeMode="CanResizeWithGrip">
<Window.Resources>
<DataTemplate DataType="{x:Type vms:AddTournametViewModel}">
<DataTemplate DataType="{x:Type vms:AddTournamentViewModel}">
<views:AddTournamentView/>
</DataTemplate>
<DataTemplate DataType="{x:Type vms:EditTournamentViewModel}">

View File

@@ -9,11 +9,11 @@ using System.Windows.Input;
namespace Apollon.WPF.ViewModels
{
public class AddTournametViewModel : ViewModelBase
public class AddTournamentViewModel : ViewModelBase
{
public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
public AddTournametViewModel(ModalNavigationStore modalNavigationStore)
public AddTournamentViewModel(ModalNavigationStore modalNavigationStore)
{
ICommand cancelCommand = new CloseModalCommand(modalNavigationStore);
AddEditDetailsViewModel = new AddEditDetailsViewModel(null, cancelCommand);

View File

@@ -11,10 +11,10 @@ namespace Apollon.WPF.ViewModels
{
public class OverviewListingViewModel : ViewModelBase
{
private readonly ObservableCollection<OverviewListingItemViewModel> _apollonOverviewListingItemViewModels;
private readonly ObservableCollection<OverviewListingItemViewModel> _OverviewListingItemViewModels;
private readonly SelectedTournamentStore _selectedTournamentStore;
public IEnumerable<OverviewListingItemViewModel> ApollonOverviewListingItemViewModels => _apollonOverviewListingItemViewModels;
public IEnumerable<OverviewListingItemViewModel> OverviewListingItemViewModels => _OverviewListingItemViewModels;
private OverviewListingItemViewModel _selectedOverviewListingItemViewModel;
@@ -37,11 +37,11 @@ namespace Apollon.WPF.ViewModels
{
_selectedTournamentStore = selectedTournamentStore;
_apollonOverviewListingItemViewModels = new ObservableCollection<OverviewListingItemViewModel>();
_OverviewListingItemViewModels = new ObservableCollection<OverviewListingItemViewModel>();
_apollonOverviewListingItemViewModels.Add(new OverviewListingItemViewModel(new Tournament("DSB", "Deutschemeisterschaft1", "Halle", "01.01.2021", "05.01.2021", "Wiesbaden",3)));
_apollonOverviewListingItemViewModels.Add(new OverviewListingItemViewModel(new Tournament("DSB", "Deutschemeisterschaft2", "im Freien", "01.01.2021", "05.01.2021", "Berlin",5)));
_apollonOverviewListingItemViewModels.Add(new OverviewListingItemViewModel(new Tournament("DSB", "Deutschemeisterschaft3", "Halle", "01.01.2021", "05.01.2021", "Bruchsal", 6)));
_OverviewListingItemViewModels.Add(new OverviewListingItemViewModel(new Tournament("DSB", "Deutschemeisterschaft1", "Halle", "01.01.2021", "05.01.2021", "Wiesbaden",3)));
_OverviewListingItemViewModels.Add(new OverviewListingItemViewModel(new Tournament("DSB", "Deutschemeisterschaft2", "im Freien", "01.01.2021", "05.01.2021", "Berlin",5)));
_OverviewListingItemViewModels.Add(new OverviewListingItemViewModel(new Tournament("DSB", "Deutschemeisterschaft3", "Halle", "01.01.2021", "05.01.2021", "Bruchsal", 6)));
}
}

View File

@@ -15,6 +15,7 @@ namespace Apollon.WPF.ViewModels
public OverviewDetailsViewModel OverviewDetailsViewModel{ get; }
public ICommand AddTournamentCommand { get; }
public ICommand EditTournamentCommand { get; }
public OverviewViewModel(SelectedTournamentStore _selectedTournamentStore, ModalNavigationStore modalNavigationStore)
{
@@ -22,6 +23,7 @@ namespace Apollon.WPF.ViewModels
OverviewDetailsViewModel = new OverviewDetailsViewModel(_selectedTournamentStore);
AddTournamentCommand = new OpenAddTournamentCommand(modalNavigationStore);
EditTournamentCommand = new OpenEditTournamentCommand(modalNavigationStore);
}
}
}

View File

@@ -18,7 +18,7 @@
Background="Transparent"
BorderBrush="Transparent"
Padding="20"
ItemsSource="{Binding ApollonOverviewListingItemViewModels}"
ItemsSource="{Binding OverviewListingItemViewModels}"
SelectedItem="{Binding SelectedOverviewListingItemViewModel}">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">

View File

@@ -7,7 +7,7 @@
xmlns:components="clr-namespace:Apollon.WPF.Views.Components"
mc:Ignorable="d">
<Grid>
<TextBlock Text="Turniers Bearbeiten"
<TextBlock Text="Turniers bearbeiten"
TextAlignment="Center"
FontFamily="Arial"
FontWeight="Bold"

View File

@@ -112,7 +112,8 @@
Height="40"
Width="210"
Margin="40"
Cursor="Hand"/>
Cursor="Hand"
Command="{Binding EditTournamentCommand}"/>
</StackPanel>
</Grid>