using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.Extensions; using BeWo.Validation; namespace BeWo.ViewModel { public class PersonOrganisationRelationVM : AbstractDCMapperVM { public static string PropertyName_Fax = "Fax"; public static string PropertyName_Mail = "Mail"; public static string PropertyName_Notice = "Notice"; public static string PropertyName_Organisation = "Organisation"; public static string PropertyName_OrganisationString = "OrganisationString"; public static string PropertyName_Phone = "Phone"; public static string PropertyName_RolleInOrganisation = "Rolle In Organisation"; private string _Fax; private string _Mail; private string _Notice; private CompactOrganisationDC _Organisation; private ValueListEntryDC _RolleInOrganisation; private string _Phone; public PersonOrganisationRelationVM(Organisation2PersonDC pDataContract) : base(pDataContract, pDataContract.Organisation2PersonOid == null) { } public string Fax { get { return this._Fax; } set { if (this.AreDifferent(this._Fax, value)) { this._Fax = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Fax, value), PropertyName_Fax); this.FirePropertyChanged(PropertyName_Fax); } } } public string Mail { get { return this._Mail; } set { if (this.AreDifferent(this._Mail, value)) { this._Mail = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Mail, value), PropertyName_Mail); this.FirePropertyChanged(PropertyName_Mail); } } } 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 CompactOrganisationDC Organisation { get { return this._Organisation; } set { if (this.AreDifferent(this._Organisation, value)) { this._Organisation = value; this.FirePropertyChanged(PropertyName_Organisation); this.FirePropertyChanged(PropertyName_OrganisationString); } } } [Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)] public string OrganisationString { get { return this._Organisation.ToStringNullCheck(); } // Validation Workaround set { if (this._Organisation != null) this._Organisation.Name = value; this.FirePropertyChanged(PropertyName_OrganisationString); } } public string Phone { get { return this._Phone; } set { if (this.AreDifferent(this._Phone, value)) { this._Phone = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Phone, value), PropertyName_Phone); this.FirePropertyChanged(PropertyName_Phone); } } } public ValueListEntryDC RolleInOrganisation { get { return this._RolleInOrganisation; } set { if (this.AreDifferent(this._RolleInOrganisation, value)) { this._RolleInOrganisation = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.RolleInOrganisation, value),PropertyName_RolleInOrganisation); this.FirePropertyChanged(PropertyName_RolleInOrganisation); } } } protected override void InitByDataContract(Organisation2PersonDC pDataContract) { if (!this.IsNew) { this._Notice = pDataContract.Notice; this._Fax = pDataContract.Fax; this._Phone = pDataContract.Phone; this._Mail = pDataContract.Mail; this._Organisation = pDataContract.Organisation; _RolleInOrganisation = pDataContract.RolleInOrganisation; } } protected override Organisation2PersonDC MapToDataContract(Organisation2PersonDC pDataContract, bool doCommit) { pDataContract.Notice = this._Notice; pDataContract.Fax = this._Fax; pDataContract.Mail = this._Mail; pDataContract.Phone = this._Phone; pDataContract.Organisation = this._Organisation; pDataContract.RolleInOrganisation = _RolleInOrganisation; return pDataContract; } } }