using System; using System.Collections.Generic; using BeWo.Validation; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; namespace BeWo.ViewModel { public class MedRecordVM : AbstractDCMapperVM { public static string PropertyName_MedName = "MedName"; public static string PropertyName_MedDate = "MedDate"; public static string PropertyName_DosageForm = "DosageForm"; public static string PropertyName_Employee = "Employee"; public static string PropertyName_Customer = "Customer"; public static string PropertyName_PrescribingDoctor = "PrescribingDoctor"; public static string PropertyName_Notice = "Notice"; private string _MedName; private DateTime? _MedDate; private string _PrescribingDoctor; private CompactCustomerDC _Customer; private CompactEmployeeDC _Employee; private DarreichungsformDC _DosageForm; private string _Notice; private List _AllDosageForms; [Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)] public string MedName { get { return _MedName; } set { if (AreDifferent(_MedName, value)) { _MedName = value; StoreDirtyInformation(AreDifferent(DataContract.MedName, value), PropertyName_MedName); FirePropertyChanged(PropertyName_MedName); } } } [Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)] public DateTime? MedDate { get { return _MedDate; } set { if (AreDifferent(_MedDate, value)) { _MedDate = value; StoreDirtyInformation(AreDifferent(DataContract.Customer, value), PropertyName_Customer); FirePropertyChanged(PropertyName_MedDate); } } } public string Notice { get { return _Notice; } set { if (AreDifferent(_Notice, value)) { _Notice = value; StoreDirtyInformation(AreDifferent(DataContract.Notice, value), PropertyName_Notice); FirePropertyChanged(PropertyName_Notice); } } } public string PrescribingDoctor { get { return _PrescribingDoctor; } set { if (AreDifferent(_PrescribingDoctor, value)) { _PrescribingDoctor = value; StoreDirtyInformation(AreDifferent(DataContract.PrescribingDoctor, value), PropertyName_PrescribingDoctor); FirePropertyChanged(PropertyName_PrescribingDoctor); } } } [Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)] public DarreichungsformDC DosageForm { get { return _DosageForm; } set { if (AreDifferent(_DosageForm, value)) { _DosageForm = value; StoreDirtyInformation(AreDifferent(DataContract.DosageForm, value), PropertyName_DosageForm); FirePropertyChanged(PropertyName_DosageForm); } } } [Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)] public CompactEmployeeDC Employee { get { return _Employee; } set { if (AreDifferent(_Employee, value)) { _Employee = value; StoreDirtyInformation(AreDifferent(DataContract.Employee, value), PropertyName_Employee); FirePropertyChanged(PropertyName_Employee); } } } public CompactCustomerDC Customer { get { return _Customer; } set { if (AreDifferent(_Customer, value)) { _Customer = value; StoreDirtyInformation(AreDifferent(DataContract.Customer, value), PropertyName_Customer); FirePropertyChanged(PropertyName_Customer); } } } public MedRecordVM(MedRecordDC pDC) : base(pDC, pDC.MedRecordOid == null) { } protected override void InitByDataContract(MedRecordDC pDataContract) { if (!IsNew) { _MedName = pDataContract.MedName; _MedDate = pDataContract.MedDate; _Customer = pDataContract.Customer; _Employee = pDataContract.Employee; _DosageForm = pDataContract.DosageForm; _PrescribingDoctor = pDataContract.PrescribingDoctor; _Notice = pDataContract.Notice; } } protected override MedRecordDC MapToDataContract(MedRecordDC pDataContract, bool doCommit) { pDataContract.MedName = _MedName; pDataContract.MedDate = _MedDate; pDataContract.Customer = _Customer; pDataContract.Employee = _Employee; pDataContract.DosageForm = _DosageForm; pDataContract.PrescribingDoctor = _PrescribingDoctor; pDataContract.Notice = _Notice; return pDataContract; } public void SetInitialDosageForm(DarreichungsformDC pDosageForm) { _DosageForm = pDosageForm; FirePropertyChanged(PropertyName_DosageForm); } } }