using System.IO;
using BeWo.Data.Entities;

using BS.Shared.DataContracts;

namespace BeWo.Service.DCEntityMapper
{
    public class ChatMessageDC_ChatMessage : AbstractIDCEntityMapper<ChatMessage, ChatMessageDC>
    {
        public override ChatMessageDC MergeWithDC(ChatMessage pEntity, ChatMessageDC pDataContract)
        {

            pDataContract.SenderPersonOid = pEntity.SenderPersonOid;
            pDataContract.EmpfängerPersonOid = pEntity.EmpfängerPersonOid;
            pDataContract.ChatText = pEntity.ChatText;
            pDataContract.Uhrzeit = pEntity.Uhrzeit;
        
            return pDataContract;
        }

        public override ChatMessage MergeWithEntity(ChatMessageDC pDataContract, ChatMessage pEntity)
        {
            pEntity.SenderPersonOid = pDataContract.SenderPersonOid;
            pEntity.EmpfängerPersonOid = pDataContract.EmpfängerPersonOid;
            pEntity.Uhrzeit = pDataContract.Uhrzeit;
            pEntity.ChatText = pDataContract.ChatText;
            
            return pEntity;
        }

        protected override bool AreDCAndEntityEqual(ChatMessageDC pDC, ChatMessage pEntity)
        {
            
            if (pDC.ChatMessagesOid == null )
            {
                return false;
            }

            return pDC.ChatMessagesOid == pEntity.Oid;
        }
    }
}