144 lines
4.6 KiB
C#
144 lines
4.6 KiB
C#
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.Diagnostics;
|
|
using System.Text;
|
|
|
|
namespace KanSan.ViewModel
|
|
{
|
|
public class TaetigkeitEditViewModel : BaseViewModel, INotifyPropertyChanged, ITaetigkeitEditViewModel
|
|
{
|
|
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
|
Fahrzeug fahrzeug;
|
|
string mitarbeiter;
|
|
DateTime zeitStempel;
|
|
decimal anzahl;
|
|
string bemerkung;
|
|
Taetigkeiten model;
|
|
bool hatGueteschutzProtokoll = false;
|
|
LeistungsverzeichnisPosition leistungsverzeichnis;
|
|
List<LeistungsverzeichnisPosition> lvPositionen;
|
|
#region getsetters
|
|
public bool HatGueteschutzProtokoll
|
|
{
|
|
get => hatGueteschutzProtokoll;
|
|
}
|
|
public Fahrzeug Fahrzeug
|
|
{
|
|
get => fahrzeug;
|
|
set
|
|
{
|
|
if (fahrzeug == value) return;
|
|
fahrzeug = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
public string Mitarbeiter
|
|
{
|
|
get => mitarbeiter;
|
|
set
|
|
{
|
|
if (mitarbeiter == value) return;
|
|
mitarbeiter = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
public DateTime ZeitStempel
|
|
{
|
|
get => zeitStempel;
|
|
set
|
|
{
|
|
if (zeitStempel == value) return;
|
|
zeitStempel = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
public bool Erledigt => !zeitStempel.Equals(DateTime.MinValue);
|
|
public decimal Anzahl
|
|
{
|
|
get => anzahl;
|
|
set
|
|
{
|
|
if (anzahl == value) return;
|
|
anzahl = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
public string Bemerkung
|
|
{
|
|
get => bemerkung;
|
|
set
|
|
{
|
|
if (bemerkung == value) return;
|
|
bemerkung = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
public LeistungsverzeichnisPosition Leistungsverzeichnis
|
|
{
|
|
get => leistungsverzeichnis;
|
|
set
|
|
{
|
|
if (leistungsverzeichnis == value) return;
|
|
leistungsverzeichnis = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
public List<LeistungsverzeichnisPosition> LVPositionen
|
|
{
|
|
get => lvPositionen;
|
|
}
|
|
#endregion
|
|
|
|
public TaetigkeitEditViewModel(Taetigkeiten taetigkeiten)
|
|
{
|
|
model = taetigkeiten;
|
|
mitarbeiter = model.Mitarbeiter;
|
|
anzahl = model.Anzahl;
|
|
zeitStempel = model.ZeitStempel;
|
|
bemerkung = model.Bemerkung;
|
|
fahrzeug = model.Fahrzeug;
|
|
leistungsverzeichnis = model.LeistungsverzeichnisPosition;
|
|
hatGueteschutzProtokoll = model.LeistungsverzeichnisPosition == null? false: model.LeistungsverzeichnisPosition.HatGueteschutzProtokol;
|
|
|
|
IEnumerable<BaustelleLeistungsverzeichnisReferenz> baustelleLeistungsverzeichnis = unitOfWork.LeistungsverzeichnisReferenz.Get(x => x.Baustelle.Equals(MainWindowViewModel.Baustelle),includeProperties:"LVPosition");
|
|
lvPositionen = new List<LeistungsverzeichnisPosition>();
|
|
// TODO auslagern
|
|
foreach(BaustelleLeistungsverzeichnisReferenz referenz in baustelleLeistungsverzeichnis)
|
|
{
|
|
if((model.LeistungsverzeichnisPosition != null) && (model.LeistungsverzeichnisPosition.GuidNr.Equals(referenz.LVPosition.GuidNr)))
|
|
{
|
|
leistungsverzeichnis = referenz.LVPosition;
|
|
}
|
|
lvPositionen.Add(referenz.LVPosition);
|
|
}
|
|
//MainWindowViewModel.LVPositionen = lvPositionen;
|
|
var x = LVPositionen.Equals(leistungsverzeichnis);
|
|
}
|
|
|
|
public void LöscheErledigt()
|
|
{
|
|
zeitStempel = DateTime.MinValue;
|
|
Mitarbeiter = String.Empty;
|
|
}
|
|
|
|
public void Speichern()
|
|
{
|
|
model.Mitarbeiter = mitarbeiter;
|
|
model.Anzahl = anzahl;
|
|
model.ZeitStempel = zeitStempel;
|
|
model.Bemerkung = bemerkung;
|
|
model.Fahrzeug = fahrzeug;
|
|
model.LeistungsverzeichnisPosition = leistungsverzeichnis;
|
|
|
|
unitOfWork.TaetigkeitenRepository.Update(model,false);
|
|
unitOfWork.Commit();
|
|
}
|
|
|
|
}
|
|
}
|