61 lines
2.2 KiB
C#
61 lines
2.2 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|
|
}
|