115 lines
2.6 KiB
C#
115 lines
2.6 KiB
C#
using KanSan.Base;
|
|
using KanSan.Base.Interfaces;
|
|
using KanSan.Base.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace KanSan.ViewModel
|
|
{
|
|
class KundeViewModel : PropertyChangedClass, INotifyPropertyChanged
|
|
{
|
|
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
|
|
|
private Kunde _kunde;
|
|
private string vorname;
|
|
private string nachname;
|
|
private string strasse;
|
|
private string plz;
|
|
private string ort;
|
|
|
|
#region getters
|
|
public string Vorname
|
|
{
|
|
get
|
|
{
|
|
return vorname;
|
|
}
|
|
set
|
|
{
|
|
if (vorname == value) return;
|
|
vorname = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
public string Nachname
|
|
{
|
|
get
|
|
{
|
|
return nachname;
|
|
}
|
|
set
|
|
{
|
|
if (nachname == value) return;
|
|
nachname = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
public string Strasse
|
|
{
|
|
get
|
|
{
|
|
return strasse;
|
|
}
|
|
set
|
|
{
|
|
if (strasse == value) return;
|
|
strasse = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
public string PLZ
|
|
{
|
|
get
|
|
{
|
|
return plz;
|
|
}
|
|
set
|
|
{
|
|
if (plz == value) return;
|
|
plz = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
public string Ort
|
|
{
|
|
get
|
|
{
|
|
return ort;
|
|
}
|
|
set
|
|
{
|
|
if (ort == value) return;
|
|
ort = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
public KundeViewModel()
|
|
{
|
|
_kunde = unitOfWork.KundenRepository.Get().First();
|
|
|
|
vorname = _kunde.Vorname;
|
|
nachname = _kunde.Nachname;
|
|
strasse = _kunde.Strasse;
|
|
plz = _kunde.PLZ;
|
|
ort = _kunde.Ort;
|
|
}
|
|
|
|
public void Speichern()
|
|
{
|
|
_kunde.Vorname = Vorname;
|
|
_kunde.Nachname = Nachname;
|
|
_kunde.Strasse = Strasse;
|
|
_kunde.Ort = Ort;
|
|
_kunde.PLZ = PLZ;
|
|
|
|
unitOfWork.KundenRepository.Update(_kunde);
|
|
unitOfWork.Commit();
|
|
}
|
|
}
|
|
}
|