57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using SewerStammGen.Shared.Contracts;
|
|
using SewerStammGen.WPF.Commands;
|
|
using SewerStammGen.WPF.Interface.Navigator;
|
|
using SewerStammGen.WPF.ViewModel.State;
|
|
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 HaltungListViewModel : BaseViewModel
|
|
{
|
|
private readonly ObservableCollection<Kanal> _haltungen;
|
|
private readonly IActualState _actualState;
|
|
private readonly IHaltungDataService _haltungDataService;
|
|
|
|
public Kanal? SelectedHaltung { get; set; }
|
|
public ObservableCollection<Kanal> Haltungen { get => _haltungen; }
|
|
|
|
public ICommand EditCommand { get; set; }
|
|
public ICommand AddCommand { get; set; }
|
|
|
|
public HaltungListViewModel(IHaltungDataService haltungDataService, IActualState actualState, IRenavigator renavigator )
|
|
{
|
|
_haltungen = new ObservableCollection<Kanal>();
|
|
|
|
_actualState = actualState;
|
|
_haltungDataService = haltungDataService;
|
|
|
|
EditCommand = new HaltungEditCommand(haltungDataService, actualState, renavigator, this);
|
|
AddCommand = new HaltungAddCommand();
|
|
|
|
LoadHaltungen();
|
|
}
|
|
|
|
private async void LoadHaltungen()
|
|
{
|
|
var haltungen = await _haltungDataService.GetAll(_actualState.ProjektID);
|
|
InitCollection(_haltungen, haltungen);
|
|
}
|
|
|
|
private void InitCollection(ObservableCollection<Kanal> dest, IEnumerable<Kanal> source)
|
|
{
|
|
dest.Clear();
|
|
foreach (var sourceItem in source)
|
|
{
|
|
dest.Add(sourceItem);
|
|
}
|
|
}
|
|
}
|
|
}
|