using System; using System.Collections.Generic; using BeWo.ViewModel; using BS.Shared.DataContracts; namespace BeWo.Scheduler.ViewModel { public class AppointmentVM : AbstractDCMapperVM, IBeWoAppointment { public static string PropertyName_AppointmentCategory = "AppointmentCategory"; public static string PropertyName_Type = "Type"; public static string PropertyName_Start = "Start"; public static string PropertyName_End = "End"; public static string PropertyName_AllDay = "AllDay"; public static string PropertyName_Subject = "Subject"; public static string PropertyName_Location = "Location"; public static string PropertyName_Status = "Status"; public static string PropertyName_RecurrenceInfo = "RecurrenceInfo"; public static string PropertyName_ReminderInfo = "ReminderInfo"; public static string PropertyName_Description = "Description"; public static string PropertyName_CustomerOid = "CustomerOid"; public static string PropertyName_EmployeeOid = "EmployeeOid"; private bool _AllDay; private AppointmentCategoryDC _AppointmentCategory; private long? _CustomerOid; private String _Description; private long? _EmployeeOid; private DateTime _End; private String _Location; private String _RecurrenceInfo; private String _ReminderInfo; private DateTime _Start; private int _Status; private String _Subject; private int _Type; private Dictionary mCustomFields; public AppointmentVM(AppointmentDC pDC) : base(pDC, pDC.AppointmentOid == null) { } public AppointmentCategoryDC AppointmentCategoryDC { get { return _AppointmentCategory; } set { if (AreDifferent(_AppointmentCategory, value)) { _AppointmentCategory = value; StoreDirtyInformation(!AreEqual(value, DataContract.AppointmentCategory), PropertyName_AppointmentCategory); FirePropertyChanged(PropertyName_AppointmentCategory); } } } public long? CustomerOid { get { return _CustomerOid; } set { if (AreDifferent(_CustomerOid, value)) { _CustomerOid = value; StoreDirtyInformation(AreDifferent(DataContract.CustomerOid, value), PropertyName_CustomerOid); FirePropertyChanged(PropertyName_CustomerOid); } } } public long? EmployeeOid { get { return _EmployeeOid; } set { if (AreDifferent(_EmployeeOid, value)) { _EmployeeOid = value; StoreDirtyInformation(AreDifferent(DataContract.EmployeeOid, value), PropertyName_EmployeeOid); FirePropertyChanged(PropertyName_EmployeeOid); } } } public int EventType { get { return _Type; } set { if (AreDifferent(_Type, value)) { _Type = value; StoreDirtyInformation(AreDifferent(DataContract.Type, value), PropertyName_Type); FirePropertyChanged(PropertyName_Type); } } } public DateTime End { get { return _End; } set { if (AreDifferent(_End, value)) { _End = value; StoreDirtyInformation(AreDifferent(DataContract.EndDate, value), PropertyName_End); FirePropertyChanged(PropertyName_End); } } } public DateTime Start { get { return _Start; } set { if (AreDifferent(_Start, value)) { _Start = value; StoreDirtyInformation(AreDifferent(DataContract.StartDate, value), PropertyName_Start); FirePropertyChanged(PropertyName_Start); } } } public bool AllDay { get { return _AllDay; } set { if (AreDifferent(_AllDay, value)) { _AllDay = value; StoreDirtyInformation(AreDifferent(DataContract.AllDay, value), PropertyName_AllDay); FirePropertyChanged(PropertyName_AllDay); } } } public String Subject { get { return _Subject; } set { if (AreDifferent(_Subject, value)) { _Subject = value; StoreDirtyInformation(AreDifferent(DataContract.Subject, value), PropertyName_Subject); FirePropertyChanged(PropertyName_Subject); } } } public String Location { get { return _Location; } set { if (AreDifferent(_Location, value)) { _Location = value; StoreDirtyInformation(AreDifferent(DataContract.Location, value), PropertyName_Location); FirePropertyChanged(PropertyName_Location); } } } public int Status { get { return _Status; } set { if (AreDifferent(_Status, value)) { _Status = value; StoreDirtyInformation(AreDifferent(DataContract.Status, value), PropertyName_Status); FirePropertyChanged(PropertyName_Status); } } } public String RecurrenceInfo { get { return _RecurrenceInfo; } set { if (AreDifferent(_RecurrenceInfo, value)) { _RecurrenceInfo = value; StoreDirtyInformation(AreDifferent(DataContract.RecurrenceInfo, value), PropertyName_RecurrenceInfo); FirePropertyChanged(PropertyName_RecurrenceInfo); } } } public String ReminderInfo { get { return _ReminderInfo; } set { if (AreDifferent(_ReminderInfo, value)) { _ReminderInfo = value; StoreDirtyInformation(AreDifferent(DataContract.ReminderInfo, value), PropertyName_ReminderInfo); FirePropertyChanged(PropertyName_ReminderInfo); } } } public String Description { get { return _Description; } set { if (AreDifferent(_Description, value)) { _Description = value; StoreDirtyInformation(AreDifferent(DataContract.Description, value), PropertyName_Description); FirePropertyChanged(PropertyName_Description); } } } public object Id { get; set; } public int LabelId { get; set; } public object ResourceId { get; set; } public BeWoAppointmentCategory AppointmentCategory { get; set; } public Dictionary CustomFields { get { return mCustomFields ?? (mCustomFields = new Dictionary()); } } protected override void InitByDataContract(AppointmentDC pDataContract) { _AllDay = pDataContract.AllDay; _AppointmentCategory = pDataContract.AppointmentCategory; _CustomerOid = pDataContract.CustomerOid; _Description = pDataContract.Description; _EmployeeOid = pDataContract.EmployeeOid; _End = pDataContract.EndDate; _Location = pDataContract.Location; _RecurrenceInfo = pDataContract.RecurrenceInfo; _ReminderInfo = pDataContract.ReminderInfo; _Start = pDataContract.StartDate; _Status = pDataContract.Status; _Subject = pDataContract.Subject; _Type = pDataContract.Type; } protected override AppointmentDC MapToDataContract(AppointmentDC pDataContract, bool doCommit) { pDataContract.AllDay = _AllDay; pDataContract.AppointmentCategory = _AppointmentCategory; pDataContract.CustomerOid = _CustomerOid; pDataContract.Description = _Description; pDataContract.EmployeeOid = _EmployeeOid; pDataContract.EndDate = _End; pDataContract.Location = _Location; pDataContract.RecurrenceInfo = _RecurrenceInfo; pDataContract.ReminderInfo = _ReminderInfo; pDataContract.StartDate = _Start; pDataContract.Status = _Status; pDataContract.Subject = _Subject; pDataContract.Type = _Type; return pDataContract; } } }