using BeWo.Validation; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.Extensions; using System; namespace BeWo.ViewModel { public class CustomerEmployeeRelationVM : AbstractDCMapperVM { public static string PropertyName_Customer = "Customer"; public static string PropertyName_CustomerString = "CustomerString"; public static string PropertyName_Employee = "Employee"; public static string PropertyName_EmployeeString = "EmployeeString"; public static string PropertyName_Notice = "Notice"; public static string PropertyName_Role = "Role"; public static string PropertyName_Chatpartner = "Chatpartner"; public static string PropertyName_StartDate = "StartDate"; public static string PropertyName_EndDate = "EndDate"; private CompactCustomerDC _Customer; private CompactEmployeeDC _Employee; private string _Notice; private ValueListEntryDC _Role; private bool _Chatpartner; private DateTime? _StartDate; private DateTime? _EndDate; public CustomerEmployeeRelationVM(CustomerEmployeeRelationDC pDC) : base(pDC, pDC.Employee2CustomerOid == null) { } [Validation(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 { } } [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); } } } public bool Chatpartner { get { return _Chatpartner; } set { if (this.AreDifferent(this._Chatpartner, value)) { _Chatpartner = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Chatpartner, value), PropertyName_Chatpartner); this.FirePropertyChanged(PropertyName_Chatpartner); } } } public DateTime? StartDate { get { return _StartDate; } set { if (this.AreDifferent(this._StartDate, value)) { _StartDate = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.StartDate, value), PropertyName_StartDate); this.FirePropertyChanged(PropertyName_StartDate); } } } public DateTime? EndDate { get { return _EndDate; } set { if (this.AreDifferent(this._EndDate, value)) { _EndDate = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.EndDate, value), PropertyName_EndDate); this.FirePropertyChanged(PropertyName_EndDate); } } } [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(CustomerEmployeeRelationDC pDataContract) { if (!this.IsNew) { this._Employee = pDataContract.Employee; this._Customer = pDataContract.Customer; this._Role = pDataContract.RelationRole; this._Notice = pDataContract.Notice; _Chatpartner = pDataContract.Chatpartner; _StartDate = pDataContract.StartDate; _EndDate = pDataContract.EndDate; } } protected override CustomerEmployeeRelationDC MapToDataContract(CustomerEmployeeRelationDC pDataContract, bool doCommit) { pDataContract.Employee = this._Employee; pDataContract.Customer = this._Customer; pDataContract.RelationRole = this._Role; pDataContract.Notice = this._Notice; pDataContract.Chatpartner = _Chatpartner; pDataContract.StartDate = _StartDate; pDataContract.EndDate = _EndDate; return pDataContract; } } }