using BS.Shared;
using BS.Shared.DataContracts;
using System;

namespace BeWo.ViewModel
{
    public class SignatureVM : AbstractDCMapperVM<SignatureDC>
    {

        public static string PropertyName_Latitute = "Latitute";

        public static string PropertyName_Longitute = "Longitute";

        public static string PropertyName_Zeitstempel = "Zeitstempel";

        private string _DataBild;

        private DateTime _Zeitstempel;

        private string _Latitute;

        private string _Longitute;

        private long? _ServiceRecordOid;


        public SignatureVM(SignatureDC pDC)
            : base(pDC, true)
        {
        }


        public virtual string DataBild
        {
            get { return this._DataBild; }

            set
            {
                if (this.AreDifferent(this._DataBild, value))
                {
                    this._DataBild = value;
                }
            }
        }

        public DateTime Zeitstempel
        {
            get { return this._Zeitstempel; }

            set
            {
                if (this.AreDifferent(this._Zeitstempel, value))
                {
                    this._Zeitstempel = value;
                    this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Zeitstempel, value), PropertyName_Zeitstempel);
                    this.FirePropertyChanged(PropertyName_Zeitstempel);
                }
            }
        }

        public string Latitute
        {
            get
            {
                return _Latitute;
            }
            set
            {
                if (this.AreDifferent(this._Latitute, value))
                {
                    this._Latitute = value;
                    this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Latitute, value), PropertyName_Latitute);
                    this.FirePropertyChanged(PropertyName_Latitute);
                }
            }
        }

        public string Longitute
        {
            get
            {
                return _Longitute;
            }
            set
            {
                if (this.AreDifferent(this._Longitute, value))
                {
                    this._Longitute = value;
                    this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Longitute, value), PropertyName_Longitute);
                    this.FirePropertyChanged(PropertyName_Longitute);
                }
            }
        }

        public virtual long? ServiceRecordOid
        {
            get
            {
                return this._ServiceRecordOid;
            }

            set
            {
                if (this.AreDifferent(this._ServiceRecordOid, value))
                {
                    this._ServiceRecordOid = value;
                }
            }
        }

        protected override void InitByDataContract(SignatureDC pDataContract)
        {
            this._DataBild = pDataContract.DataBild;
            this._Latitute = pDataContract.Latitute;
            this._Longitute = pDataContract.Longitute;
            this._Zeitstempel = pDataContract.Zeitstempel;
            this._ServiceRecordOid = pDataContract.ServiceRecordOid;
        }

        protected override SignatureDC MapToDataContract(SignatureDC pDataContract, bool doCommit)
        {
            pDataContract.DataBild = _DataBild;
            pDataContract.Latitute = _Latitute;
            pDataContract.Longitute = _Longitute;
            
            pDataContract.Zeitstempel = _Zeitstempel;
            pDataContract.ServiceRecordOid = _ServiceRecordOid;

            return pDataContract;
        }
    }
}