157 lines
4.8 KiB
C#
157 lines
4.8 KiB
C#
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using BeWo.ViewModel.ListViewModel;
|
|
|
|
namespace BeWo.ViewModel
|
|
{
|
|
public class ArbeitszeitVM : AbstractDCMapperVM<ArbeitszeitDC>
|
|
{
|
|
public static string PropertyName_GueltigVon = "GueltigVon";
|
|
|
|
public static string PropertyName_GueltigBis = "GueltigBis";
|
|
|
|
public static string PropertyName_Notice = "Notice";
|
|
|
|
public static string PropertyName_ArbeitszeitEintragListeVM = "ArbeitszeitEintragListeVM";
|
|
|
|
public static string PropertyName_ArbeitszeitString = "ArbeitszeitString";
|
|
|
|
private DateTime? _GueltigVon;
|
|
|
|
private DateTime? _GueltigBis;
|
|
|
|
private string _Notice;
|
|
|
|
private ArbeitszeitEintragListVM _ArbeitszeitEintraege;
|
|
|
|
|
|
public ArbeitszeitVM(ArbeitszeitDC pDC)
|
|
: base(pDC, pDC.ArbeitszeitOid == null)
|
|
{
|
|
}
|
|
|
|
public override bool IsDirty
|
|
{
|
|
get
|
|
{
|
|
return base.IsDirty || (_ArbeitszeitEintraege != null && _ArbeitszeitEintraege.IsDirty);
|
|
}
|
|
}
|
|
|
|
public DateTime? GueltigVon
|
|
{
|
|
get { return this._GueltigVon; }
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._GueltigVon, value))
|
|
{
|
|
this._GueltigVon = value;
|
|
this.StoreDirtyInformation(this.AreDifferent(this.DataContract.GueltigVon, value), PropertyName_GueltigVon);
|
|
this.FirePropertyChanged(PropertyName_GueltigVon);
|
|
this.FirePropertyChanged(PropertyName_ArbeitszeitString);
|
|
}
|
|
}
|
|
}
|
|
|
|
public DateTime? GueltigBis
|
|
{
|
|
get { return this._GueltigBis; }
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._GueltigBis, value))
|
|
{
|
|
this._GueltigBis = value;
|
|
this.StoreDirtyInformation(this.AreDifferent(this.DataContract.GueltigBis, value), PropertyName_GueltigBis);
|
|
this.FirePropertyChanged(PropertyName_GueltigBis);
|
|
this.FirePropertyChanged(PropertyName_ArbeitszeitString);
|
|
}
|
|
}
|
|
}
|
|
|
|
public string Notice
|
|
{
|
|
get { return _Notice; }
|
|
|
|
set
|
|
{
|
|
if (AreDifferent(_Notice, value))
|
|
{
|
|
_Notice = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Notice, value), PropertyName_Notice);
|
|
FirePropertyChanged(PropertyName_Notice);
|
|
}
|
|
}
|
|
}
|
|
|
|
public string ArbeitszeitString
|
|
{
|
|
get
|
|
{
|
|
String text = "";
|
|
if (this._GueltigVon.HasValue)
|
|
{
|
|
text = String.Format("Arbeitszeit vom {0:dd.MM.yyyy}", this._GueltigVon);
|
|
|
|
if (this._GueltigBis.HasValue)
|
|
{
|
|
text += String.Format(" - {0:dd.MM.yyyy}", this._GueltigBis);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this._GueltigBis.HasValue)
|
|
{
|
|
text = String.Format("Arbeitszeit bis {0:dd.MM.yyyy}", this._GueltigBis);
|
|
}
|
|
}
|
|
if (String.IsNullOrEmpty(text))
|
|
{
|
|
if (this.IsNew)
|
|
text = "Neue Arbeitszeit";
|
|
else
|
|
text = "Arbeitszeit";
|
|
}
|
|
return text;
|
|
}
|
|
|
|
set { }
|
|
}
|
|
|
|
|
|
|
|
public ArbeitszeitEintragListVM ArbeitszeitEintraege
|
|
{
|
|
get { return _ArbeitszeitEintraege; }
|
|
set
|
|
{
|
|
_ArbeitszeitEintraege = value;
|
|
FirePropertyChanged(PropertyName_ArbeitszeitEintragListeVM);
|
|
}
|
|
}
|
|
|
|
protected override void InitByDataContract(ArbeitszeitDC pDataContract)
|
|
{
|
|
this._GueltigBis = pDataContract.GueltigBis;
|
|
this._GueltigVon = pDataContract.GueltigVon;
|
|
this._Notice = pDataContract.Notice;
|
|
|
|
ArbeitszeitEintraege = VMFactory.CreateArbeitszeitEintragListVm(pDataContract.Eintraege ?? (pDataContract.Eintraege = new List<ArbeitszeitEintragDC>()));
|
|
|
|
}
|
|
|
|
protected override ArbeitszeitDC MapToDataContract(ArbeitszeitDC pDataContract, bool doCommit)
|
|
{
|
|
pDataContract.GueltigVon = _GueltigVon;
|
|
pDataContract.GueltigBis = _GueltigBis;
|
|
pDataContract.Notice = _Notice;
|
|
|
|
pDataContract.Eintraege = _ArbeitszeitEintraege.CopyToDCList(doCommit);
|
|
|
|
return pDataContract;
|
|
}
|
|
}
|
|
} |