Esempio n. 1
0
        public List <PrivateChatMessage> GetScrollingChatData(string fromid, string toid, int start = 10, int length = 1)
        {
            takeCounter = (length * start);       // 20
            skipCounter = ((length - 1) * start); // 10
            ChatPrivateMessageMasterRepository <ChatPrivateMessageMaster>   chpmm = new ChatPrivateMessageMasterRepository <ChatPrivateMessageMaster>();
            ChatPrivateMessageDetailsRepository <ChatPrivateMessageDetails> chpmd = new ChatPrivateMessageDetailsRepository <ChatPrivateMessageDetails>();

            //using (Surajit_TestEntities dc = new Surajit_TestEntities())
            //{
            List <PrivateChatMessage> msg = new List <PrivateChatMessage>();
            var v = (from a in chpmm.GetList().ToList()
                     join b in chpmd.GetList().ToList() on a.EmailID equals b.MasterEmailID into cc
                     from c in cc
                     where (c.MasterEmailID.Equals(fromid) && c.ChatToEmailID.Equals(toid)) || (c.MasterEmailID.Equals(toid) && c.ChatToEmailID.Equals(fromid))
                     orderby c.Id descending
                     select new
            {
                UserName = a.UserName,
                Message = c.Message,
                ID = c.Id
            }).Take(takeCounter).Skip(skipCounter).ToList();

            foreach (var a in v)
            {
                var res = new PrivateChatMessage()
                {
                    userName = a.UserName,
                    message  = a.Message
                };
                msg.Add(res);
            }
            return(msg);
            // }
        }
Esempio n. 2
0
        public List <PrivateChatMessage> GetPrivateMessage(string fromid, string toid, int take)
        {
            ChatPrivateMessageMasterRepository <ChatPrivateMessageMaster>   chpmm = new ChatPrivateMessageMasterRepository <ChatPrivateMessageMaster>();
            ChatPrivateMessageDetailsRepository <ChatPrivateMessageDetails> chpmd = new ChatPrivateMessageDetailsRepository <ChatPrivateMessageDetails>();

            //using (Surajit_TestEntities dc = new Surajit_TestEntities())
            //{
            List <PrivateChatMessage> msg = new List <PrivateChatMessage>();

            var v = (from a in chpmm.GetList().ToList()
                     join b in chpmd.GetList().ToList() on a.EmailID equals b.MasterEmailID into cc
                     from c in cc
                     where (c.MasterEmailID.Equals(fromid) && c.ChatToEmailID.Equals(toid)) || (c.MasterEmailID.Equals(toid) && c.ChatToEmailID.Equals(fromid))
                     orderby c.Id descending
                     select new
            {
                UserName = a.UserName,
                Message = c.Message,
                ID = c.Id
            }).Take(take).ToList();

            v = v.OrderBy(s => s.ID).ToList();

            foreach (var a in v)
            {
                var res = new PrivateChatMessage()
                {
                    userName = a.UserName,
                    message  = a.Message
                };
                msg.Add(res);
            }
            return(msg);
            //}
        }
Esempio n. 3
0
        private void AddPrivateMessageinCache(string fromEmail, string chatToEmail, string userName, string message)
        {
            ChatPrivateMessageMasterRepository <ChatPrivateMessageMaster> chmmr = new ChatPrivateMessageMasterRepository <ChatPrivateMessageMaster>();
            //using (Surajit_TestEntities dc = new Surajit_TestEntities())
            //{
            // Save master
            var master = chmmr.GetList(new { EmailID = fromEmail }).ToList();//dc.ChatPrivateMessageMasters.ToList().Where(a => a.EmailID.Equals(fromEmail)).ToList();

            if (master.Count == 0)
            {
                var result = new ChatPrivateMessageMaster
                {
                    EmailID  = fromEmail,
                    UserName = userName
                };
                chmmr.Insert(result);// dc.ChatPrivateMessageMasters.Add(result);
                //dc.SaveChanges();
            }

            // Save details
            var resultDetails = new ChatPrivateMessageDetails
            {
                MasterEmailID = fromEmail,
                ChatToEmailID = chatToEmail,
                Message       = message
            };

            ChatPrivateMessageDetailsRepository <ChatPrivateMessageDetails> chpmd = new ChatPrivateMessageDetailsRepository <ChatPrivateMessageDetails>();

            chpmd.Insert(resultDetails);// dc.ChatPrivateMessageDetails.Add(resultDetails);
            // dc.SaveChanges();
            // }
        }