using System; using BeWo.Validation; using BS.Shared; using BS.Shared.DataContracts; namespace BeWo.ViewModel { public class NotizenEintragVM : AbstractDCMapperVM { public static string PropertyName_Datum = "Datum"; public static string PropertyName_Notice = "Notice"; public static string PropertyName_EintragKategorieDC = "EintragKategorieDC"; private DateTime? _Datum; private string _Notice; private ValueListEntryDC _EintragKategorieDC; public NotizenEintragVM(NotizenEintragDC pDataContract) : base(pDataContract, pDataContract.NotizenEintragOid == null) { } public string Notice { get { return _Notice; } set { if (AreDifferent(_Notice, value)) { _Notice = value; StoreDirtyInformation(AreDifferent(DataContract.Notice, value), PropertyName_Notice); FirePropertyChanged(PropertyName_Notice); } } } public ValueListEntryDC EintragKategorieDC { get { return _EintragKategorieDC; } set { if (AreDifferent(_EintragKategorieDC, value)) { if (value != null && value.ValueListEntryOid.Value == -1) { _EintragKategorieDC = null; } else { _EintragKategorieDC = value; } StoreDirtyInformation(AreDifferent(DataContract.EintragKategorieDC, value), nameof(EintragKategorieDC)); FirePropertyChanged(nameof(EintragKategorieDC)); } } } [Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)] public DateTime? Datum { get { return _Datum; } set { if (!AreDifferent(_Datum, value)) { return; } _Datum = value; StoreDirtyInformation(AreDifferent(DataContract.Datum, value), PropertyName_Datum); FirePropertyChanged(PropertyName_Datum); } } public String InsUser { get { return DataContract.InsUser; } } public DateTime? InsTs { get { return DataContract.InsTs; } } protected override void InitByDataContract(NotizenEintragDC pDataContract) { //if (!IsNew) //{ _Datum = pDataContract.Datum; _Notice = pDataContract.Notice; _EintragKategorieDC = pDataContract.EintragKategorieDC; //} } protected override NotizenEintragDC MapToDataContract(NotizenEintragDC pDataContract, bool doCommit) { pDataContract.Datum = _Datum; pDataContract.Notice = _Notice; pDataContract.EintragKategorieDC = _EintragKategorieDC; return pDataContract; } } }