2016-06-27 01:45:38 +02:00
|
|
|
|
using BeWo.Validation;
|
2017-03-24 10:30:18 +01:00
|
|
|
|
using BS.Shared.Core;
|
2016-06-27 01:45:38 +02:00
|
|
|
|
using BS.Shared.DataContracts;
|
|
|
|
|
|
using BS.Shared.DataContracts.Compact;
|
|
|
|
|
|
using BS.Shared.Extensions;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BeWo.ViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
public class CustomerPersonRelationVM : AbstractDCMapperVM<CustomerPersonRelationDC>
|
|
|
|
|
|
{
|
|
|
|
|
|
public static string PropertyName_Notice = "Notice";
|
|
|
|
|
|
|
|
|
|
|
|
public static string PropertyName_Person = "Person";
|
|
|
|
|
|
|
2016-12-08 14:17:41 +01:00
|
|
|
|
public static string PropertyName_Organisation = "Organisation";
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
public static string PropertyName_PersonString = "PersonString";
|
|
|
|
|
|
|
2016-12-08 14:17:41 +01:00
|
|
|
|
public static string PropertyName_OrganisationString = "OrganisationString";
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
public static string PropertyName_AddressSummaryInfo = "AddressSummaryInfo";
|
|
|
|
|
|
|
|
|
|
|
|
public static string PropertyName_ContactSummaryInfo = "ContactSummaryInfo";
|
|
|
|
|
|
|
|
|
|
|
|
public static string PropertyName_Role = "Role";
|
|
|
|
|
|
|
2017-02-16 13:26:43 +01:00
|
|
|
|
public static string PropertyName_IstFamilie = "IstFamilie";
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
private string _Notice;
|
|
|
|
|
|
|
|
|
|
|
|
private CompactPersonDC _Person;
|
|
|
|
|
|
|
2016-12-08 14:17:41 +01:00
|
|
|
|
private CompactOrganisationDC _Organisation;
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
private ValueListEntryDC _Role;
|
|
|
|
|
|
|
2017-02-16 13:26:43 +01:00
|
|
|
|
private bool _IstFamilie;
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
public CustomerPersonRelationVM(CustomerPersonRelationDC pDC) : base(pDC, pDC.Customer2PersonOid == null) { }
|
|
|
|
|
|
|
2017-02-16 13:26:43 +01:00
|
|
|
|
public bool IstFamilie
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _IstFamilie; }
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (AreDifferent(_IstFamilie, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
_IstFamilie = value;
|
|
|
|
|
|
StoreDirtyInformation(AreDifferent(DataContract.IstFamilie, value), PropertyName_IstFamilie);
|
|
|
|
|
|
FirePropertyChanged(PropertyName_IstFamilie);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
public string Notice
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _Notice; }
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (AreDifferent(_Notice, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
_Notice = value;
|
|
|
|
|
|
StoreDirtyInformation(AreDifferent(DataContract.Customer2PersonNotice, value), PropertyName_Notice);
|
|
|
|
|
|
FirePropertyChanged(PropertyName_Notice);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CompactPersonDC Person
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _Person; }
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (AreDifferent(_Person, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
_Person = value;
|
|
|
|
|
|
StoreDirtyInformation(AreDifferent(DataContract.Person, value), PropertyName_Person);
|
|
|
|
|
|
FirePropertyChanged(PropertyName_Person);
|
|
|
|
|
|
FirePropertyChanged(PropertyName_PersonString);
|
|
|
|
|
|
FirePropertyChanged(PropertyName_AddressSummaryInfo);
|
|
|
|
|
|
FirePropertyChanged(PropertyName_ContactSummaryInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-12-08 14:17:41 +01:00
|
|
|
|
public CompactOrganisationDC Organisation
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _Organisation; }
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (AreDifferent(_Organisation, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
_Organisation = value;
|
|
|
|
|
|
StoreDirtyInformation(AreDifferent(DataContract.Organisation, value), PropertyName_Organisation);
|
|
|
|
|
|
FirePropertyChanged(PropertyName_Organisation);
|
|
|
|
|
|
FirePropertyChanged(PropertyName_OrganisationString);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
[Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
|
|
|
|
|
|
public string PersonString
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _Person.ToStringNullCheck(); } // Validation Workaround
|
|
|
|
|
|
set { }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-12-08 14:17:41 +01:00
|
|
|
|
[Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
|
|
|
|
|
|
public string OrganisationString
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _Organisation.ToStringNullCheck(); } // Validation Workaround
|
|
|
|
|
|
set { }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
public string AddressSummaryInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var address = _Person.Street;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(address))
|
|
|
|
|
|
{
|
|
|
|
|
|
address += "\n";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (address == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
address = string.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
address += _Person.PostalCode + " " + _Person.Town;
|
|
|
|
|
|
|
|
|
|
|
|
return address;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set { }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string ContactSummaryInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var info = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_Person.Communication1))
|
|
|
|
|
|
{
|
|
|
|
|
|
info = "Tel.: " + _Person.Communication1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_Person.Communication2))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (info.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
info += "\n";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
info += "Mobil: " + _Person.Communication2;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_Person.Communication3))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (info.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
info += "\n";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
info += "E-Mail: " + _Person.Communication3;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_Person.Communication4))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (info.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
info += "\n";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
info += "Fax: " + _Person.Communication4;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return info;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set { }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[ValidationAttribute(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
|
|
|
|
|
|
public ValueListEntryDC Role
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _Role; }
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (AreDifferent(_Role, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
_Role = value;
|
|
|
|
|
|
StoreDirtyInformation(AreDifferent(DataContract.RelationRole, value), PropertyName_Role);
|
|
|
|
|
|
FirePropertyChanged(PropertyName_Role);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-03-24 10:30:18 +01:00
|
|
|
|
public string FamilyStatus
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_Person.FamilyStatus.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
return EnumTranslations.FamilyStatusTranslations[_Person.FamilyStatus];
|
|
|
|
|
|
}
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
set { }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
protected override void InitByDataContract(CustomerPersonRelationDC pDataContract)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!IsNew)
|
|
|
|
|
|
{
|
|
|
|
|
|
_Notice = pDataContract.Customer2PersonNotice;
|
|
|
|
|
|
_Person = pDataContract.Person;
|
|
|
|
|
|
_Role = pDataContract.RelationRole;
|
2016-12-08 14:17:41 +01:00
|
|
|
|
_Organisation = pDataContract.Organisation;
|
2017-02-16 13:26:43 +01:00
|
|
|
|
_IstFamilie = pDataContract.IstFamilie;
|
2016-06-27 01:45:38 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override CustomerPersonRelationDC MapToDataContract(CustomerPersonRelationDC pDataContract, bool doCommit)
|
|
|
|
|
|
{
|
|
|
|
|
|
pDataContract.Customer2PersonNotice = _Notice;
|
|
|
|
|
|
pDataContract.Person = _Person;
|
|
|
|
|
|
pDataContract.RelationRole = _Role;
|
2016-12-08 14:17:41 +01:00
|
|
|
|
pDataContract.Organisation = _Organisation;
|
2017-02-16 13:26:43 +01:00
|
|
|
|
pDataContract.IstFamilie = _IstFamilie;
|
2016-06-27 01:45:38 +02:00
|
|
|
|
|
|
|
|
|
|
return pDataContract;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|