131 lines
4.1 KiB
C#
131 lines
4.1 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 : PropertyChangedClass, INotifyPropertyChanged, ITaetigkeitEditViewModel
|
|
{
|
|
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
|
Fahrzeug fahrzeug;
|
|
string mitarbeiter;
|
|
DateTime zeitStempel;
|
|
decimal anzahl;
|
|
string bemerkung;
|
|
Taetigkeiten model;
|
|
LeistungsverzeichnisPosition leistungsverzeichnis;
|
|
List<LeistungsverzeichnisPosition> lvPositionen;
|
|
#region getsetters
|
|
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;
|
|
|
|
IEnumerable<BaustelleLeistungsverzeichnisReferenz> baustelleLeistungsverzeichnis = unitOfWork.LeistungsverzeichnisReferenz.Get(x => x.Baustelle.Equals(MainWindowViewModel.Baustelle),includeProperties:"LVPosition");
|
|
lvPositionen = new List<LeistungsverzeichnisPosition>();
|
|
foreach(BaustelleLeistungsverzeichnisReferenz referenz in baustelleLeistungsverzeichnis)
|
|
{
|
|
if(model.LeistungsverzeichnisPosition.GuidNr.Equals(referenz.LVPosition.GuidNr))
|
|
{
|
|
leistungsverzeichnis = referenz.LVPosition;
|
|
}
|
|
Trace.WriteLine(referenz.LVPosition.Equals(model.LeistungsverzeichnisPosition));
|
|
lvPositionen.Add(referenz.LVPosition);
|
|
}
|
|
var x = LVPositionen.Equals(leistungsverzeichnis);
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
}
|
|
}
|