Exemplo n.º 1
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();
            // }
        }
Exemplo n.º 2
0
        public static void AddPrivateMessageinCache(string fromEmail, string chatToEmail, string userName, string message)
        {
            using (var dc = new SolutionsOnlineSellingEntities())
            {
                // Save master
                var master = dc.ChatPrivateMessageMaster.ToList().Where(a => a.EmailID.Equals(fromEmail)).ToList();
                if (master.Count == 0)
                {
                    var result = new ChatPrivateMessageMaster
                    {
                        EmailID  = fromEmail,
                        UserName = userName
                    };
                    dc.ChatPrivateMessageMaster.Add(result);
                    dc.SaveChanges();
                }

                // Save details
                var resultDetails = new ChatPrivateMessageDetails
                {
                    MasterEmailID = fromEmail,
                    ChatToEmailID = chatToEmail,
                    Message       = message
                };
                dc.ChatPrivateMessageDetails.Add(resultDetails);
                dc.SaveChanges();
            }
        }