using BeWo.Validation; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.Extensions; namespace BeWo.ViewModel { public class WohnheimEmployeeRelationVM : AbstractDCMapperVM { public static string PropertyName_Wohnheim = "Wohnheim"; public static string PropertyName_WohnheimString = "WohnheimString"; public static string PropertyName_Employee = "Employee"; public static string PropertyName_EmployeeString = "EmployeeString"; public static string PropertyName_Notice = "Notice"; public static string PropertyName_Role = "Role"; private CompactWohnheimDC _Wohnheim; private CompactEmployeeDC _Employee; private string _Notice; private ValueListEntryDC _Role; public WohnheimEmployeeRelationVM(WohnheimEmployeeRelationDC pDC) : base(pDC, pDC.Employee2WohnheimOid == null) { } [Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)] public CompactWohnheimDC Wohnheim { get { return this._Wohnheim; } set { if (this.AreDifferent(this._Wohnheim, value)) { this._Wohnheim = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Wohnheim, value), PropertyName_Wohnheim); this.FirePropertyChanged(PropertyName_Wohnheim); this.FirePropertyChanged(PropertyName_WohnheimString); } } } [ValidationAttribute(ValidationRule = ValidationRules.NotNullOrStringEmpty)] public string WohnheimString { get { return this._Wohnheim.ToStringNullCheck(); } // Validation Workaround set { } } [ValidationAttribute(ValidationRule = ValidationRules.NotNullOrStringEmpty)] public CompactEmployeeDC Employee { get { return this._Employee; } set { if (this.AreDifferent(this._Employee, value)) { this._Employee = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Employee, value), PropertyName_Employee); this.FirePropertyChanged(PropertyName_Employee); this.FirePropertyChanged(PropertyName_EmployeeString); } } } [ValidationAttribute(ValidationRule = ValidationRules.NotNullOrStringEmpty)] public string EmployeeString { get { return this._Employee.ToStringNullCheck(); } // Validation Workaround set { } } public string Notice { get { return this._Notice; } set { if (this.AreDifferent(this._Notice, value)) { this._Notice = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Notice, value), PropertyName_Notice); this.FirePropertyChanged(PropertyName_Notice); } } } [Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)] public ValueListEntryDC Role { get { return this._Role; } set { if (this.AreDifferent(this._Role, value)) { this._Role = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.RelationRole, value), PropertyName_Role); this.FirePropertyChanged(PropertyName_Role); } } } protected override void InitByDataContract(WohnheimEmployeeRelationDC pDataContract) { if (!this.IsNew) { this._Employee = pDataContract.Employee; this._Wohnheim = pDataContract.Wohnheim; this._Role = pDataContract.RelationRole; this._Notice = pDataContract.Notice; } } protected override WohnheimEmployeeRelationDC MapToDataContract(WohnheimEmployeeRelationDC pDataContract, bool doCommit) { pDataContract.Employee = this._Employee; pDataContract.Wohnheim = this._Wohnheim; pDataContract.RelationRole = this._Role; pDataContract.Notice = this._Notice; return pDataContract; } } }