Refactoring durchgeführt

This commit is contained in:
HuskyTeufel
2021-09-14 17:08:06 +02:00
parent 6b2ed0d5ab
commit 8eccf7c478
24 changed files with 430 additions and 57 deletions

View File

@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>disable</Nullable>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@@ -1,5 +1,6 @@
using DaSaSo.Domain.Model; using DaSaSo.Domain.Model;
using DaSaSo.Domain.Services; using DaSaSo.Domain.Services;
using DaSaSo.EntityFramework.Services.Common;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.ChangeTracking;
using System; using System;
@@ -13,31 +14,22 @@ namespace DaSaSo.EntityFramework.Services
public class ClientDataService : IDataService<Client> public class ClientDataService : IDataService<Client>
{ {
private readonly DaSaSoDbContextFactory _contextFactory; private readonly DaSaSoDbContextFactory _contextFactory;
private readonly NonQueryDataService<Client> _nonQueryDataService;
public ClientDataService(DaSaSoDbContextFactory contextFactory) public ClientDataService(DaSaSoDbContextFactory contextFactory)
{ {
_contextFactory = contextFactory; _contextFactory = contextFactory;
_nonQueryDataService = new NonQueryDataService<Client>(contextFactory);
} }
public async Task<Client> Create(Client entity) public async Task<Client> Create(Client entity)
{ {
using (DaSaSoDbContext context = _contextFactory.CreateDbContext()) return await _nonQueryDataService.Create(entity);
{
EntityEntry<Client> createdResult = await context.Set<Client>().AddAsync(entity);
await context.SaveChangesAsync();
return createdResult.Entity;
}
} }
public async Task<bool> Delete(int id) public async Task<bool> Delete(int id)
{ {
using (DaSaSoDbContext context = _contextFactory.CreateDbContext()) return await _nonQueryDataService.Delete(id);
{
Client entity = await context.Set<Client>().FirstOrDefaultAsync((e) => e.Id == id);
context.Set<Client>().Remove(entity);
await context.SaveChangesAsync();
return true;
}
} }
public async Task<Client> Get(int id) public async Task<Client> Get(int id)
@@ -54,7 +46,7 @@ namespace DaSaSo.EntityFramework.Services
{ {
using (DaSaSoDbContext context = _contextFactory.CreateDbContext()) using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
{ {
IEnumerable<Client> entities = await context.Set<Client>().ToListAsync(); IEnumerable<Client> entities = await context.Clients.ToListAsync();
return entities; return entities;
} }
@@ -62,13 +54,7 @@ namespace DaSaSo.EntityFramework.Services
public async Task<Client> Update(int id, Client entity) public async Task<Client> Update(int id, Client entity)
{ {
using (DaSaSoDbContext context = _contextFactory.CreateDbContext()) return await _nonQueryDataService.Update(id, entity);
{
entity.Id = id;
context.Set<Client>().Update(entity);
await context.SaveChangesAsync();
return entity;
}
} }
} }
} }

View File

@@ -0,0 +1,51 @@
using DaSaSo.Domain.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DaSaSo.EntityFramework.Services.Common
{
class NonQueryDataService<T> where T: DomainObject
{
private readonly DaSaSoDbContextFactory _contextFactory;
public NonQueryDataService(DaSaSoDbContextFactory contextFactory)
{
_contextFactory = contextFactory;
}
public async Task<T> Create(T entity)
{
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
{
EntityEntry<T> createdEntity = await context.Set<T>().AddAsync(entity);
await context.SaveChangesAsync();
return createdEntity.Entity;
}
}
public async Task<bool> Delete(int id)
{
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
{
T entity = await context.Set<T>().FirstOrDefaultAsync((e) => e.Id == id);
context.Set<T>().Remove(entity);
await context.SaveChangesAsync();
return true;
}
}
public async Task<T> Update(int id, T entity)
{
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
{
entity.Id = id;
context.Set<T>().Update(entity);
await context.SaveChangesAsync();
return entity;
}
}
}
}

View File

@@ -1,5 +1,6 @@
using DaSaSo.Domain.Model; using DaSaSo.Domain.Model;
using DaSaSo.Domain.Services; using DaSaSo.Domain.Services;
using DaSaSo.EntityFramework.Services.Common;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.ChangeTracking;
using System; using System;
@@ -13,31 +14,22 @@ namespace DaSaSo.EntityFramework.Services
public class GenericDataService<T> : IDataService<T> where T : DomainObject public class GenericDataService<T> : IDataService<T> where T : DomainObject
{ {
private readonly DaSaSoDbContextFactory _contextFactory; private readonly DaSaSoDbContextFactory _contextFactory;
private readonly NonQueryDataService<T> _nonQueryDataService;
public GenericDataService(DaSaSoDbContextFactory contextFactory) public GenericDataService(DaSaSoDbContextFactory contextFactory)
{ {
this._contextFactory = contextFactory; this._contextFactory = contextFactory;
_nonQueryDataService = new NonQueryDataService<T>(contextFactory);
} }
public async Task<T> Create(T entity) public async Task<T> Create(T entity)
{ {
using (DaSaSoDbContext context = _contextFactory.CreateDbContext()) return await _nonQueryDataService.Create(entity);
{
EntityEntry<T> createdEntity = await context.Set<T>().AddAsync(entity);
await context.SaveChangesAsync();
return createdEntity.Entity;
}
} }
public async Task<bool> Delete(int id) public async Task<bool> Delete(int id)
{ {
using (DaSaSoDbContext context = _contextFactory.CreateDbContext()) return await _nonQueryDataService.Delete(id);
{
T entity = await context.Set<T>().FirstOrDefaultAsync((e) => e.Id == id);
context.Set<T>().Remove(entity);
await context.SaveChangesAsync();
return true;
}
} }
public async Task<T> Get(int id) public async Task<T> Get(int id)
@@ -62,13 +54,7 @@ namespace DaSaSo.EntityFramework.Services
public async Task<T> Update(int id, T entity) public async Task<T> Update(int id, T entity)
{ {
using (DaSaSoDbContext context = _contextFactory.CreateDbContext()) return await _nonQueryDataService.Update(id, entity);
{
entity.Id = id;
context.Set<T>().Update(entity);
await context.SaveChangesAsync();
return entity;
}
} }
} }
} }

View File

@@ -58,7 +58,7 @@ namespace DaSaSo.ViewModel
_dataService = dataService; _dataService = dataService;
//LoadClient(); LoadClient();
SelectClientCommand = new RelayCommand(SelectClient, () => SelectedClient != null); SelectClientCommand = new RelayCommand(SelectClient, () => SelectedClient != null);
EditClientCommand = new RelayCommand(EditClient, () => SelectedClient != null); EditClientCommand = new RelayCommand(EditClient, () => SelectedClient != null);
AddNewClientCommand = new RelayCommand(AddNewClient); AddNewClientCommand = new RelayCommand(AddNewClient);

View File

@@ -0,0 +1,33 @@
using DaSaSo.ViewModel.Enums;
using DaSaSo.ViewModel.Interface;
using System.Windows.Input;
namespace DaSaSo.ViewModel.Commands
{
class UpdateCurrentViewModelCommand : ICommand
{
public event EventHandler? CanExecuteChanged;
private INavigator _navigator;
private readonly IViewModelAbstractFactory _viewModelFactory;
public UpdateCurrentViewModelCommand(INavigator navigator, IViewModelAbstractFactory viewModelFactory)
{
_navigator = navigator;
_viewModelFactory = viewModelFactory;
}
public bool CanExecute(object? parameter)
{
return true;
}
public void Execute(object? parameter)
{
if(parameter is EViewType)
{
EViewType viewType = (EViewType)parameter;
_navigator.CurrentViewModel = _viewModelFactory.CreateViewModel(viewType);
}
}
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DaSaSo.ViewModel.Enums
{
public enum EViewType
{
Home,
Clients,
Projects,
Buildingsites,
SewerObjects
}
}

View File

@@ -0,0 +1,20 @@
using DaSaSo.Domain.Model;
using DaSaSo.EntityFramework;
using DaSaSo.EntityFramework.Services;
using DaSaSo.ViewModel.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DaSaSo.ViewModel.Factories
{
public class ClientListViewModelFactory : IViewModelFactory<ClientListViewModel>
{
public ClientListViewModel CreateViewModel()
{
return new ClientListViewModel(new GenericDataService<Client>(new DaSaSoDbContextFactory()));
}
}
}

View File

@@ -0,0 +1,17 @@
using DaSaSo.ViewModel.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DaSaSo.ViewModel.Factories
{
public class HomeViewModelFactory : IViewModelFactory<HomeViewModel>
{
public HomeViewModel CreateViewModel()
{
return new HomeViewModel();
}
}
}

View File

@@ -0,0 +1,46 @@
using DaSaSo.Domain.Model;
using DaSaSo.EntityFramework;
using DaSaSo.EntityFramework.Services;
using DaSaSo.ViewModel.Enums;
using DaSaSo.ViewModel.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DaSaSo.ViewModel.Factories
{
public class ViewModelAbstractFactory : IViewModelAbstractFactory
{
private IViewModelFactory<HomeViewModel> _homeViewModelFactory;
private IViewModelFactory<ClientListViewModel> _clientListViewModel;
public ViewModelAbstractFactory(IViewModelFactory<HomeViewModel> homeViewModelFactory, IViewModelFactory<ClientListViewModel> clientListViewModel)
{
_homeViewModelFactory = homeViewModelFactory;
_clientListViewModel = clientListViewModel;
}
public BaseViewModel CreateViewModel(EViewType viewType)
{
switch (viewType)
{
case EViewType.Home:
return _homeViewModelFactory.CreateViewModel();
case EViewType.Clients:
return _clientListViewModel.CreateViewModel();
/*case EViewType.Projects:
break;
case EViewType.Buildingsites:
break;
case EViewType.SewerObjects:
break;
*/
default:
throw new ArgumentException("The Viewtype dos not have a ViewModel.", "viewType");
}
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DaSaSo.ViewModel
{
public class HomeViewModel : BaseViewModel
{
public string Welcome { get => "Herzlich willkommen"; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace DaSaSo.ViewModel.Interface
{
public interface INavigator
{
BaseViewModel CurrentViewModel { get; set; }
ICommand UpdateViewModelCommand { get; }
}
}

View File

@@ -0,0 +1,14 @@
using DaSaSo.ViewModel.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DaSaSo.ViewModel.Interface
{
public interface IViewModelAbstractFactory
{
BaseViewModel CreateViewModel(EViewType viewType);
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DaSaSo.ViewModel.Interface
{
public interface IViewModelFactory<T> where T: BaseViewModel
{
T CreateViewModel();
}
}

View File

@@ -0,0 +1,35 @@
using DaSaSo.ViewModel.Commands;
using DaSaSo.ViewModel.Interface;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Input;
namespace DaSaSo.ViewModel.State.Navigation
{
public class Navigator : INavigator, INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
private BaseViewModel _currentViewModel;
public BaseViewModel CurrentViewModel
{
get => _currentViewModel;
set
{
_currentViewModel = value;
OnPropertyChanged();
}
}
public ICommand UpdateViewModelCommand { get; set; }
public Navigator(IViewModelAbstractFactory viewModelFactory)
{
UpdateViewModelCommand = new UpdateCurrentViewModelCommand(this, viewModelFactory);
}
protected void OnPropertyChanged([CallerMemberName]string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@@ -1,6 +1,9 @@
using DaSaSo.Domain.Model; using DaSaSo.Domain.Model;
using DaSaSo.EntityFramework; using DaSaSo.EntityFramework;
using DaSaSo.EntityFramework.Services; using DaSaSo.EntityFramework.Services;
using DaSaSo.ViewModel.Enums;
using DaSaSo.ViewModel.Interface;
using DaSaSo.ViewModel.State.Navigation;
using Microsoft.Toolkit.Mvvm.Input; using Microsoft.Toolkit.Mvvm.Input;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -18,6 +21,8 @@ namespace DaSaSo.ViewModel
private Client _selectedClient; private Client _selectedClient;
private Project _selectedProject; private Project _selectedProject;
private Buildingsite _selectedBuildingsite; private Buildingsite _selectedBuildingsite;
public INavigator Navigator { get; set; }
public IRelayCommand ListClientsCommand { get; set; } public IRelayCommand ListClientsCommand { get; set; }
public IRelayCommand ListProjectCommand { get; set; } public IRelayCommand ListProjectCommand { get; set; }
@@ -85,8 +90,10 @@ namespace DaSaSo.ViewModel
} }
} }
} }
public MainWindowViewModel() public MainWindowViewModel(INavigator navigator)
{ {
this.Navigator = navigator;
Navigator.UpdateViewModelCommand.Execute(EViewType.Home);
ListClientsCommand = new RelayCommand(showClients); ListClientsCommand = new RelayCommand(showClients);
ListProjectCommand = new RelayCommand(listProjecte, () => SelectedClient != null); ListProjectCommand = new RelayCommand(listProjecte, () => SelectedClient != null);
ListBuildingsiteCommand = new RelayCommand(listBuildingsite, () => SelectedProject != null); ListBuildingsiteCommand = new RelayCommand(listBuildingsite, () => SelectedProject != null);

View File

@@ -4,6 +4,9 @@ using DaSaSo.Domain.Services.ClientServices;
using DaSaSo.EntityFramework; using DaSaSo.EntityFramework;
using DaSaSo.EntityFramework.Services; using DaSaSo.EntityFramework.Services;
using DaSaSo.ViewModel; using DaSaSo.ViewModel;
using DaSaSo.ViewModel.Factories;
using DaSaSo.ViewModel.Interface;
using DaSaSo.ViewModel.State.Navigation;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -23,19 +26,27 @@ namespace DaSaSo.Wpf
protected override async void OnStartup(StartupEventArgs e) protected override async void OnStartup(StartupEventArgs e)
{ {
IServiceProvider serviceProvider = CreateServiceProvider(); IServiceProvider serviceProvider = CreateServiceProvider();
IDataService<Client> clientService = new ClientDataService(new DaSaSoDbContextFactory());
var d = await clientService.GetAll(); MainWindow? window = new MainWindow() { DataContext = serviceProvider.GetRequiredService<MainWindowViewModel>() };
base.OnStartup(e);
MainWindow? window = new MainWindow() { DataContext = new MainWindowViewModel() };
window.Show(); window.Show();
base.OnStartup(e);
} }
private IServiceProvider CreateServiceProvider() private IServiceProvider CreateServiceProvider()
{ {
IServiceCollection services = new ServiceCollection(); IServiceCollection services = new ServiceCollection();
services.AddSingleton<DaSaSoDbContext>(); services.AddSingleton<DaSaSoDbContextFactory>();
//services.AddSingleton<IDataService<Client>, ClientDataService>(); services.AddSingleton<IDataService<Client>, ClientDataService>();
services.AddSingleton<IViewModelAbstractFactory, ViewModelAbstractFactory>();
services.AddSingleton<IViewModelFactory<HomeViewModel>, HomeViewModelFactory>();
services.AddSingleton<IViewModelFactory<ClientListViewModel>, ClientListViewModelFactory>();
services.AddScoped<INavigator, Navigator>();
services.AddScoped<MainWindowViewModel>();
return services.BuildServiceProvider(); return services.BuildServiceProvider();
} }

View File

@@ -0,0 +1,22 @@
<UserControl x:Class="DaSaSo.Wpf.Controls.NavigationBar"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DaSaSo.Wpf.Controls"
xmlns:nav="clr-namespace:DaSaSo.ViewModel.Enums;assembly=DaSaSo.ViewModel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<RadioButton Grid.Row="0" Content="Kunden" Style="{StaticResource ToggleButtonList}" Command="{Binding UpdateViewModelCommand}" CommandParameter="{x:Static nav:EViewType.Clients}" />
<RadioButton Grid.Row="1" Content="Projekte" Style="{StaticResource ToggleButtonList}" Command="{Binding UpdateViewModelCommand}" CommandParameter="{x:Static nav:EViewType.Projects}" />
<RadioButton Grid.Row="2" Content="Baustellen" Style="{StaticResource ToggleButtonList}" Command="{Binding UpdateViewModelCommand}" CommandParameter="{x:Static nav:EViewType.Buildingsites}" />
<RadioButton Grid.Row="3" Content="Objekten" Style="{StaticResource ToggleButtonList}" Command="{Binding UpdateViewModelCommand}" CommandParameter="{x:Static nav:EViewType.SewerObjects}" />
</Grid>
</UserControl>

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DaSaSo.Wpf.Controls
{
/// <summary>
/// Interaction logic for NavigationBar.xaml
/// </summary>
public partial class NavigationBar : UserControl
{
public NavigationBar()
{
InitializeComponent();
}
}
}

View File

@@ -7,26 +7,41 @@
</ApplicationDefinition> </ApplicationDefinition>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="Controls\NavigationBar.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="View\Client\ClientEditView.xaml.cs"> <Compile Update="View\Client\ClientEditView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Update="View\Client\ClientListView.xaml.cs"> <Compile Update="View\Client\ClientListView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Update="View\HomeView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="View\Project\ProjectListView.xaml.cs"> <Compile Update="View\Project\ProjectListView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Update="Controls\NavigationBar.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="my_controls.xaml"> <Page Update="my_controls.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="Styles\Navigation_Style.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="View\Client\ClientEditView.xaml"> <Page Update="View\Client\ClientEditView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="View\Client\ClientListView.xaml"> <Page Update="View\Client\ClientListView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="View\HomeView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="View\Project\ProjectListView.xaml"> <Page Update="View\Project\ProjectListView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>

View File

@@ -0,0 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</ResourceDictionary>

View File

@@ -0,0 +1,12 @@
<UserControl x:Class="DaSaSo.Wpf.View.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DaSaSo.Wpf.View" xmlns:viewmodel="clr-namespace:DaSaSo.ViewModel;assembly=DaSaSo.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:HomeViewModel}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<TextBlock Text="{Binding Welcome }" />
</Grid>
</UserControl>

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DaSaSo.Wpf.View
{
/// <summary>
/// Interaction logic for HomeView.xaml
/// </summary>
public partial class HomeView : UserControl
{
public HomeView()
{
InitializeComponent();
}
}
}

View File

@@ -5,6 +5,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ClientViews="clr-namespace:DaSaSo.Wpf.View.Client" xmlns:ClientViews="clr-namespace:DaSaSo.Wpf.View.Client"
xmlns:ProjektViews="clr-namespace:DaSaSo.Wpf.View.Project" xmlns:ProjektViews="clr-namespace:DaSaSo.Wpf.View.Project"
xmlns:controls="clr-namespace:DaSaSo.Wpf.Controls"
xmlns:View="clr-namespace:DaSaSo.Wpf.View"
xmlns:local="clr-namespace:DaSaSo.Wpf" xmlns:viewmodel="clr-namespace:DaSaSo.ViewModel;assembly=DaSaSo.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:MainWindowViewModel}" xmlns:local="clr-namespace:DaSaSo.Wpf" xmlns:viewmodel="clr-namespace:DaSaSo.ViewModel;assembly=DaSaSo.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:MainWindowViewModel}"
mc:Ignorable="d" mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800"> Title="MainWindow" Height="450" Width="800">
@@ -18,6 +20,9 @@
<DataTemplate DataType="{x:Type viewmodel:ProjectListViewModel}"> <DataTemplate DataType="{x:Type viewmodel:ProjectListViewModel}">
<ProjektViews:ProjectListView /> <ProjektViews:ProjectListView />
</DataTemplate> </DataTemplate>
<DataTemplate DataType="{x:Type viewmodel:HomeViewModel}">
<View:HomeView />
</DataTemplate>
</Window.Resources> </Window.Resources>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@@ -28,13 +33,8 @@
<RowDefinition /> <RowDefinition />
<RowDefinition Height="20" /> <RowDefinition Height="20" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Grid.Column="0" Grid.Row="0"> <controls:NavigationBar Grid.Column="0" Grid.Row="0" DataContext="{Binding Navigator }" />
<RadioButton Content="Kunden" Style="{StaticResource ToggleButtonList}" Command="{Binding ListClientsCommand}" /> <ContentControl Grid.Column="1" Grid.Row="0" Content="{Binding Navigator.CurrentViewModel}" />
<RadioButton Content="Projekte" Style="{StaticResource ToggleButtonList}" Command="{Binding ListProjectCommand}" />
<RadioButton Content="Baustellen" Style="{StaticResource ToggleButtonList}" Command="{Binding ListBuildingsiteCommand}" />
<RadioButton Content="Objekte" Style="{StaticResource ToggleButtonList}" Command="{Binding ListSewerObjectsCommand}" />
</StackPanel>
<ContentControl Grid.Column="1" Grid.Row="0" Content="{Binding ActualViewModel}" />
<StatusBar Grid.Row="1" Grid.ColumnSpan="2"> <StatusBar Grid.Row="1" Grid.ColumnSpan="2">
<StatusBarItem Content="{Binding SelectedClient.Firstname}" /> <StatusBarItem Content="{Binding SelectedClient.Firstname}" />
</StatusBar> </StatusBar>