Schächte werden nun hinzugefügt

This commit is contained in:
2023-03-31 15:01:39 +02:00
parent 70bba66df3
commit d4b38ff7ae
33 changed files with 927 additions and 30 deletions

View File

@@ -11,37 +11,38 @@ namespace SewerStammGen.WPF.ViewModel.Factories
public class MainWindowViewModelFactory : IViewModelAbstractFactory
{
private CreateViewModel<HomeViewModel> _createHomeViewModel;
private CreateViewModel<EditManHoleViewModel> _createEditManholeViewModel;
private CreateViewModel<ManholeEditViewModel> _createManholeEditViewModel;
private CreateViewModel<ManholeListViewModel> _createManholeListViewModel;
private CreateViewModel<SewerConnectorViewModel> _createSewerConnectorViewModel;
private CreateViewModel<ProjektListViewModel> _createProjektListViewModel;
public MainWindowViewModelFactory(
CreateViewModel<HomeViewModel> createHomeViewModel,
CreateViewModel<EditManHoleViewModel> createEditManholeViewModel,
CreateViewModel<ManholeEditViewModel> createManholeEditViewModel,
CreateViewModel<ManholeListViewModel> createManholeListViewModel,
CreateViewModel<SewerConnectorViewModel> createSewerConnectorViewModel,
CreateViewModel<ProjektListViewModel> createProjektListViewModel
)
{
_createHomeViewModel = createHomeViewModel;
_createEditManholeViewModel = createEditManholeViewModel;
_createManholeEditViewModel = createManholeEditViewModel;
_createSewerConnectorViewModel = createSewerConnectorViewModel;
_createProjektListViewModel = createProjektListViewModel;
_createManholeListViewModel = createManholeListViewModel;
}
public BaseViewModel CreateViewModel(EMainWindowViewType viewType)
{
switch(viewType)
{
case EMainWindowViewType.Home:
return _createHomeViewModel();
case EMainWindowViewType.Home: return _createHomeViewModel();
case EMainWindowViewType.EditSchacht:
return _createEditManholeViewModel();
case EMainWindowViewType.SchachtList: return _createManholeListViewModel();
case EMainWindowViewType.SchachtEdit: return _createManholeEditViewModel();
case EMainWindowViewType.SewerConnectionEdit:
return _createSewerConnectorViewModel();
case EMainWindowViewType.SewerConnectionEdit: return _createSewerConnectorViewModel();
case EMainWindowViewType.ProjectsList: return _createProjektListViewModel();
case EMainWindowViewType.ProjectList: return _createProjektListViewModel();
default:
throw new NotImplementedException();

View File

@@ -45,6 +45,12 @@ namespace SewerStammGen.WPF.ViewModel
Navigator.StateChanged += Navigator_StateChanged;
#if DEBUG
_actualState.ProjektID = 5;
#endif
}
private void ActualState_ProjektChanged(object? sender, EventArgs e)

View File

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace SewerStammGen.WPF.ViewModel
{
public class EditManHoleViewModel : BaseViewModel
public class ManholeEditViewModel : BaseViewModel
{
}
}

View File

@@ -0,0 +1,60 @@
using SewerStammGen.Shared.Contracts;
using SewerStammGen.WPF.Commands;
using SewerStammGen.WPF.Interface.Navigator;
using SewerStammGen.WPF.ViewModel.State;
using Shared.Contracts;
using Shared.Domain;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace SewerStammGen.WPF.ViewModel
{
public class ManholeListViewModel : BaseViewModel
{
private ISchachtDataService _schachtService;
private readonly ObservableCollection<Schacht> _schaechte;
private readonly IActualState _actualState;
private readonly ISchachtService _schachtServicer;
public ObservableCollection<Schacht> Schaechte { get => _schaechte; }
public ICommand AddSchachtCommand { get; set; }
public ICommand EditSchachtCommand { get; set; }
public ICommand DeleteSchachtCommand { get; set; }
public ManholeListViewModel(ISchachtDataService schachtService, IDataService<Projekt> projektService,IRenavigator renavigator ,IActualState actualState, ISchachtService schachtServicer)
{
_schachtService = schachtService;
_actualState = actualState;
_schaechte = new ObservableCollection<Schacht>();
_schachtServicer = schachtServicer;
AddSchachtCommand = new SchachtAddCommand(schachtService,projektService, actualState,renavigator,schachtServicer);
EditSchachtCommand = new SchachtEditCommand(schachtService, actualState, renavigator,this);
DeleteSchachtCommand = new SchachtDeleteCommand(schachtService, actualState, renavigator, this);
LoadSchaechte();
}
private async void LoadSchaechte()
{
var schaechte = await _schachtService.GetAll(_actualState.ProjektID);
InitCollection(_schaechte, schaechte);
}
private void InitCollection(ObservableCollection<Schacht> dest, IEnumerable<Schacht> source)
{
dest.Clear();
foreach(var i in source)
{
dest.Add(i);
}
}
}
}

View File

@@ -9,7 +9,8 @@ namespace SewerStammGen.WPF.ViewModel.State
{
internal class ActualState : IActualState
{
public int ProjektID { get; private set; }
// TODO: set auf private set setzen
public int ProjektID { get; set; }
public void SetProjekt(Projekt projekt, bool notification = true)
{

View File

@@ -10,8 +10,8 @@ namespace SewerStammGen.WPF.ViewModel.State
public interface IActualState
{
event EventHandler? ProjektChanged;
int ProjektID { get; }
// TODO: ProjektID set entfernen!
int ProjektID { get; set; }
void SetProjekt(Projekt projekt, bool notification = true);
}