Client wird gespeichert mittels interface
This commit is contained in:
@@ -17,44 +17,22 @@ namespace DaSaSo.ViewModel
|
||||
{
|
||||
public sealed class MainWindowViewModel : BaseViewModel
|
||||
{
|
||||
private BaseViewModel _actualViewModel;
|
||||
|
||||
private Client _selectedClient;
|
||||
private Project _selectedProject;
|
||||
private Buildingsite _selectedBuildingsite;
|
||||
|
||||
public INavigator Navigator { get; set; }
|
||||
|
||||
public IRelayCommand ListClientsCommand { get; set; }
|
||||
public IRelayCommand ListProjectCommand { get; set; }
|
||||
public IRelayCommand ListBuildingsiteCommand { get; set; }
|
||||
public IRelayCommand ListSewerObjectsCommand { get; set; }
|
||||
|
||||
public BaseViewModel ActualViewModel
|
||||
{
|
||||
get => _actualViewModel;
|
||||
set
|
||||
{
|
||||
if(_actualViewModel != value)
|
||||
{
|
||||
_actualViewModel = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
public Project SelectedProject
|
||||
{
|
||||
get => _selectedProject;
|
||||
set
|
||||
{
|
||||
if(value == null)
|
||||
{
|
||||
ListBuildingsiteCommand.NotifyCanExecuteChanged();
|
||||
}
|
||||
if(_selectedProject != value && value != null)
|
||||
if(_selectedProject != value)
|
||||
{
|
||||
_selectedProject = value;
|
||||
OnPropertyChanged();
|
||||
ListBuildingsiteCommand.NotifyCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,15 +41,10 @@ namespace DaSaSo.ViewModel
|
||||
get => _selectedBuildingsite;
|
||||
set
|
||||
{
|
||||
if(value == null)
|
||||
{
|
||||
ListSewerObjectsCommand.NotifyCanExecuteChanged();
|
||||
}
|
||||
if(_selectedBuildingsite != value && value != null)
|
||||
if(_selectedBuildingsite != value)
|
||||
{
|
||||
_selectedBuildingsite = value;
|
||||
OnPropertyChanged();
|
||||
ListSewerObjectsCommand.NotifyCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,9 +57,8 @@ namespace DaSaSo.ViewModel
|
||||
if(_selectedClient != value)
|
||||
{
|
||||
_selectedClient = value;
|
||||
SelectedProject = null;
|
||||
//SelectedProject = null;
|
||||
OnPropertyChanged();
|
||||
ListProjectCommand.NotifyCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,10 +66,7 @@ namespace DaSaSo.ViewModel
|
||||
{
|
||||
this.Navigator = navigator;
|
||||
Navigator.UpdateViewModelCommand.Execute(EViewType.Home);
|
||||
ListClientsCommand = new RelayCommand(showClients);
|
||||
ListProjectCommand = new RelayCommand(listProjecte, () => SelectedClient != null);
|
||||
ListBuildingsiteCommand = new RelayCommand(listBuildingsite, () => SelectedProject != null);
|
||||
ListSewerObjectsCommand = new RelayCommand(listSewerObjects, () => SelectedBuildingsite != null);
|
||||
|
||||
|
||||
Mediator.Subscribe(Enums.EMediator.SELECTEDCLIENT, (tt) =>
|
||||
{
|
||||
@@ -107,20 +76,14 @@ namespace DaSaSo.ViewModel
|
||||
|
||||
Mediator.Subscribe(Enums.EMediator.EDITCLIENT, (tt) =>
|
||||
{
|
||||
ActualViewModel = new ClientEditViewModel(new GenericDataService<Client>(new DaSaSoDbContextFactory()),
|
||||
(Client)tt);
|
||||
|
||||
});
|
||||
Mediator.Subscribe(Enums.EMediator.SHOWCLIENT, (tt) => {
|
||||
ActualViewModel = null;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void showClients()
|
||||
{
|
||||
ClientListViewModel clientListViewModel = new ClientListViewModel(new GenericDataService<Client>(new DaSaSoDbContextFactory()));
|
||||
ActualViewModel = clientListViewModel;
|
||||
clientListViewModel.LoadClient();
|
||||
}
|
||||
|
||||
|
||||
private void listSewerObjects()
|
||||
{
|
||||
@@ -134,8 +97,7 @@ namespace DaSaSo.ViewModel
|
||||
|
||||
private void listProjecte()
|
||||
{
|
||||
Debugger.Break();
|
||||
ActualViewModel = new ProjectListViewModel(new GenericDataService<Project>(new DaSaSoDbContextFactory()),SelectedClient);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user