using BeWo.Validation; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.Extensions; namespace BeWo.ViewModel { public class WohnheimCustomerRelationVM : AbstractDCMapperVM { public static string PropertyName_Wohnheim = "Wohnheim"; public static string PropertyName_WohnheimString = "WohnheimString"; public static string PropertyName_Customer = "Customer"; public static string PropertyName_CustomerString = "CustomerString"; public static string PropertyName_Notice = "Notice"; public static string PropertyName_Role = "Role"; private CompactWohnheimDC _Wohnheim; private CompactCustomerDC _Customer; private string _Notice; private ValueListEntryDC _Role; public WohnheimCustomerRelationVM(WohnheimCustomerRelationDC pDC) : base(pDC, pDC.Customer2WohnheimOid == 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 CompactCustomerDC Customer { get { return this._Customer; } set { if (this.AreDifferent(this._Customer, value)) { this._Customer = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Customer, value), PropertyName_Customer); this.FirePropertyChanged(PropertyName_Customer); this.FirePropertyChanged(PropertyName_CustomerString); } } } [ValidationAttribute(ValidationRule = ValidationRules.NotNullOrStringEmpty)] public string CustomerString { get { return this._Customer.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(WohnheimCustomerRelationDC pDataContract) { if (!this.IsNew) { this._Customer = pDataContract.Customer; this._Wohnheim = pDataContract.Wohnheim; this._Role = pDataContract.RelationRole; this._Notice = pDataContract.Notice; } } protected override WohnheimCustomerRelationDC MapToDataContract(WohnheimCustomerRelationDC pDataContract, bool doCommit) { pDataContract.Customer = this._Customer; pDataContract.Wohnheim = this._Wohnheim; pDataContract.RelationRole = this._Role; pDataContract.Notice = this._Notice; return pDataContract; } } }