Ejemplo 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

            using (Surajit_TestEntities dc = new Surajit_TestEntities())
            {
                List <PrivateChatMessage> msg = new List <PrivateChatMessage>();
                var v = (from a in dc.ChatPrivateMessageMasters
                         join b in dc.ChatPrivateMessageDetails 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);
            }
        }
Ejemplo n.º 2
0
        public List <PrivateChatMessage> GetPrivateMessage(string fromid, string toid, int take)
        {
            using (Surajit_TestEntities dc = new Surajit_TestEntities())
            {
                List <PrivateChatMessage> msg = new List <PrivateChatMessage>();

                var v = (from a in dc.ChatPrivateMessageMasters
                         join b in dc.ChatPrivateMessageDetails 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);
            }
        }