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

namespace BeWo.ViewModel
{
    public class ChatMessageVM : AbstractDCMapperVM<ChatMessageDC>
    {
        public static string PropertyName_ChatText = "ChatText";

        public static string PropertyName_Uhrzeit = "Uhrzeit";

        private string _ChatText;

        private DateTime _Uhrzeit;

        private long? _SenderPersonOid;

        private long? _EmpfängerPersonOid;


        public ChatMessageVM(ChatMessageDC pDC)
            : base(pDC, true)
        {
        }


        public virtual string ChatText
        {
            get { return this._ChatText; }

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

        public DateTime Uhrzeit
        {
            get { return this._Uhrzeit; }

            set
            {
                if (this.AreDifferent(this._Uhrzeit, value))
                {
                    this._Uhrzeit = value;
                    this.StoreDirtyInformation(this.AreDifferent(DataContract.Uhrzeit, value), PropertyName_Uhrzeit);
                    this.FirePropertyChanged(PropertyName_Uhrzeit);
                }
            }
        }

        public virtual long? SenderPersonOid
        {
            get
            {
                return this._SenderPersonOid;
            }

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

        public virtual long? EmpfängerPersonOid
        {
            get
            {
                return this._EmpfängerPersonOid;
            }

            set
            {
                if (this.AreDifferent(this._EmpfängerPersonOid, value))
                {
                    this._EmpfängerPersonOid = value;
                }
            }
        }


        protected override void InitByDataContract(ChatMessageDC pDataContract)
        {
            this._SenderPersonOid = pDataContract.SenderPersonOid;
            this._EmpfängerPersonOid = pDataContract.EmpfängerPersonOid;
            this._Uhrzeit = pDataContract.Uhrzeit;
            this._ChatText = pDataContract.ChatText;
        }

        protected override ChatMessageDC MapToDataContract(ChatMessageDC pDataContract, bool doCommit)
        {
            pDataContract.SenderPersonOid = _SenderPersonOid;
            pDataContract.EmpfängerPersonOid = _EmpfängerPersonOid;
            pDataContract.Uhrzeit = _Uhrzeit;
            pDataContract.ChatText = _ChatText; 

            return pDataContract;
        }
    }
}