using System;

using BS.Shared.DataContracts;

namespace BeWo.ViewModel
{
    public class AssessmentSheetEntryVM : AbstractDCMapperVM<AssessmentSheetEntryDC>
    {
        public static string PropertyName_CategoryOid = "CategoryOid";

        public static string PropertyName_CustomerOid = "CustomerOid";

        public static string PropertyName_Day = "Day";

        public static string PropertyName_ValueOid = "ValueOid";

        private long? _CategoryOid;

        private long? _CustomerOid;

        private DateTime? _Day;

        private long? _ValueOid;

        public AssessmentSheetEntryVM(AssessmentSheetEntryDC pDC) : base(pDC, pDC.AssessmentSheetEntryOid == null)
        {
        }

        public long? CategoryOid
        {
            get { return this._CategoryOid; }

            set
            {
                if (this.AreDifferent(this._CategoryOid, value))
                {
                    this._CategoryOid = value;
                    this.StoreDirtyInformation(this.AreDifferent(this.DataContract.AssessmentSheetCategoryOid, value), PropertyName_CategoryOid);
                    this.FirePropertyChanged(PropertyName_CategoryOid);
                }
            }
        }

        public long? CustomerOid
        {
            get { return this._CustomerOid; }

            set
            {
                if (this.AreDifferent(this._CustomerOid, value))
                {
                    this._CustomerOid = value;
                    this.StoreDirtyInformation(this.AreDifferent(this.DataContract.CustomerOid, value), PropertyName_CustomerOid);
                    this.FirePropertyChanged(PropertyName_CustomerOid);
                }
            }
        }

        public DateTime? Day
        {
            get { return this._Day; }

            set
            {
                if (this.AreDifferent(this._Day, value))
                {
                    this._Day = value;
                    this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Day, value), PropertyName_Day);
                    this.FirePropertyChanged(PropertyName_Day);
                }
            }
        }

        public long? ValueOid
        {
            get { return this._ValueOid; }

            set
            {
                if (this.AreDifferent(this._ValueOid, value))
                {
                    this._ValueOid = value;
                    this.StoreDirtyInformation(this.AreDifferent(this.DataContract.AssessmentSheetValueOid, value), PropertyName_ValueOid);
                    this.FirePropertyChanged(PropertyName_ValueOid);
                }
            }
        }

        protected override void InitByDataContract(AssessmentSheetEntryDC pDataContract)
        {
            this._ValueOid = pDataContract.AssessmentSheetValueOid;
            this._CustomerOid = pDataContract.CustomerOid;
            this._CategoryOid = pDataContract.AssessmentSheetCategoryOid;
            this._Day = pDataContract.Day;
        }

        protected override AssessmentSheetEntryDC MapToDataContract(AssessmentSheetEntryDC pDataContract, bool doCommit)
        {
            pDataContract.AssessmentSheetValueOid = this._ValueOid;
            pDataContract.CustomerOid = this._CustomerOid;
            pDataContract.AssessmentSheetCategoryOid = this._CategoryOid;
            pDataContract.Day = this._Day;

            return pDataContract;
        }
    }
}