65 lines
2.2 KiB
C#
65 lines
2.2 KiB
C#
using SewerStammGen.Shared.Contracts;
|
|
using SewerStammGen.Shared.Domain;
|
|
using StammGenerator.Commands;
|
|
using StammGenerator.Interface;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Windows.Input;
|
|
|
|
namespace StammGenerator.ViewModel
|
|
{
|
|
public class ManholeListViewModel : BaseViewModel
|
|
{
|
|
private readonly ISchachtDataService _schachtDataService;
|
|
private readonly ObservableCollection<Schacht> _schaechte;
|
|
private readonly IActualState _actualState;
|
|
private readonly IRenavigator renavigateToImport;
|
|
|
|
public ObservableCollection<Schacht> Schaechte { get => _schaechte; }
|
|
|
|
public Schacht? SelectedSchacht { get; set; }
|
|
|
|
public ICommand AddSchachtCommand { get; set; }
|
|
public ICommand EditSchachtCommand { get; set; }
|
|
public ICommand DeleteSchachtCommand { get; set; }
|
|
public ICommand ImportSchachtCommand { get; set; }
|
|
|
|
|
|
|
|
public ManholeListViewModel(ISchachtDataService schachtDataService, IRenavigator renavigator ,IActualState actualState, IRenavigator navigatetoImport)
|
|
{
|
|
_schachtDataService = schachtDataService;
|
|
_actualState = actualState;
|
|
|
|
_schaechte = new ObservableCollection<Schacht>();
|
|
renavigateToImport = navigatetoImport;
|
|
|
|
AddSchachtCommand = new SchachtAddCommand(actualState,renavigator);
|
|
EditSchachtCommand = new SchachtEditCommand(actualState, renavigator,this);
|
|
DeleteSchachtCommand = new SchachtDeleteCommand(schachtDataService, actualState, renavigator, this);
|
|
ImportSchachtCommand = new RelayCommand((x) =>
|
|
{
|
|
navigatetoImport.Renavigate();
|
|
});
|
|
|
|
|
|
LoadSchaechte();
|
|
}
|
|
|
|
private async void LoadSchaechte()
|
|
{
|
|
var schaechte = await _schachtDataService.GetAllByProjekt(_actualState.ProjektID);
|
|
InitCollection(_schaechte, schaechte);
|
|
}
|
|
|
|
private void InitCollection(ObservableCollection<Schacht> dest, IEnumerable<Schacht> source)
|
|
{
|
|
dest.Clear();
|
|
foreach(var i in source)
|
|
{
|
|
dest.Add(i);
|
|
}
|
|
}
|
|
}
|
|
}
|