Imprägnierungsliste hinzugefügt
This commit is contained in:
53
DaSaSo.ViewModel/ImpregnierungListViewModel.cs
Normal file
53
DaSaSo.ViewModel/ImpregnierungListViewModel.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using DaSaSo.Domain.Model;
|
||||
using DaSaSo.Domain.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DaSaSo.ViewModel
|
||||
{
|
||||
public class ImpregnierungListViewModel : BaseViewModel
|
||||
{
|
||||
public ObservableCollection<Impregnation> Impregnations;
|
||||
private readonly IDataService<Impregnation> _impregnationService;
|
||||
bool _isLoading;
|
||||
|
||||
public bool IsLoading {
|
||||
get => _isLoading;
|
||||
set
|
||||
{
|
||||
if(_isLoading != value)
|
||||
{
|
||||
_isLoading = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ImpregnierungListViewModel(IDataService<Impregnation> impregnationService)
|
||||
{
|
||||
IsLoading = true;
|
||||
Impregnations = new ObservableCollection<Impregnation>();
|
||||
_impregnationService = impregnationService;
|
||||
LoadImpregnations();
|
||||
|
||||
}
|
||||
|
||||
private async void LoadImpregnations()
|
||||
{
|
||||
var impregList = await _impregnationService.GetAll();
|
||||
InitCollection(Impregnations, impregList);
|
||||
IsLoading = false;
|
||||
}
|
||||
|
||||
private void InitCollection(ObservableCollection<Impregnation> target, IEnumerable<Impregnation> source)
|
||||
{
|
||||
target.Clear();
|
||||
foreach (var i in source)
|
||||
target.Add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user