using KanSan.Base; using KanSan.Base.Interfaces; using KanSan.Base.Interfaces.UI; using KanSan.Base.Models; using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; namespace KanSan.ViewModel { public class LeistungsverzeichnisPositionViewModel : BaseViewModel, INotifyPropertyChanged, ILeistungsverzeichnisPositionViewModel { IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext()); LeistungsverzeichnisPosition model; string positionsnummer; string beschreibung; string einheit; string tag; bool hatGüteschutzProtokoll; public string Positionsnummer { get => positionsnummer; set { if (positionsnummer == value) return; positionsnummer = value; OnPropertyChanged(); } } public string Beschreibung { get => beschreibung; set { if (beschreibung == value) return; beschreibung = value; OnPropertyChanged(); } } public string Einheit { get => einheit; set { if (einheit == value) return; einheit = value; OnPropertyChanged(); } } public string Tag { get => tag; set { if (tag == value) return; tag = value; OnPropertyChanged(); } } public bool HatGüteschutzProtokoll { get => hatGüteschutzProtokoll; set { if (hatGüteschutzProtokoll == value) return; hatGüteschutzProtokoll = value; OnPropertyChanged(); } } public LeistungsverzeichnisPositionViewModel(LeistungsverzeichnisPosition position) { this.model = position; positionsnummer = model.Positionsnummer; beschreibung = model.Beschreibung; einheit = model.Einheit; tag = model.Tag; hatGüteschutzProtokoll = model.HatGueteschutzProtokol; } public void Speichern() { model.Positionsnummer = positionsnummer; model.Beschreibung = beschreibung; model.Einheit = einheit; model.Tag = tag; model.HatGueteschutzProtokol = hatGüteschutzProtokoll; unitOfWork.LeistungsverzeichnisRepository.Update(model); unitOfWork.Commit(); } } }