Пример #1
0
 public static List <ChatMessageDetail> GetCurrentMessages()
 {
     using (var dc = new SolutionsOnlineSellingEntities())
     {
         return(dc.ChatMessageDetail.ToList());
     }
 }
Пример #2
0
        public static List <PrivateChatMessage> GetPrivateMessage(string fromid, string toid, int take)
        {
            using (var dc = new SolutionsOnlineSellingEntities())
            {
                var msg = new List <PrivateChatMessage>();

                var v = (from a in dc.ChatPrivateMessageMaster
                         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);
            }
        }
Пример #3
0
 public static ChatUserDetail GetUser(string id)
 {
     using (var dc = new SolutionsOnlineSellingEntities())
     {
         return(dc.ChatUserDetail.FirstOrDefault(x => x.ConnectionId == id));
     }
 }
Пример #4
0
 public static List <ChatUserDetail> GetConnectedUsers()
 {
     using (var dc = new SolutionsOnlineSellingEntities())
     {
         return(dc.ChatUserDetail.ToList());
     }
 }
Пример #5
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();
            }
        }
Пример #6
0
        public static ChatUserDetail GetUser(string userName, string email, string id)
        {
            using (var dc = new SolutionsOnlineSellingEntities())
            {
                var item = dc.ChatUserDetail.FirstOrDefault(x => x.EmailID == email);
                if (item != null)
                {
                    dc.ChatUserDetail.Remove(item);
                    dc.SaveChanges();
                }

                var Users = dc.ChatUserDetail.ToList();
                if (Users.Where(x => x.EmailID == email).ToList().Count == 0)
                {
                    var userdetails = new ChatUserDetail
                    {
                        ConnectionId = id,
                        UserName     = userName,
                        EmailID      = email
                    };
                    dc.ChatUserDetail.Add(userdetails);
                    dc.SaveChanges();
                }

                return(dc.ChatUserDetail.FirstOrDefault(x => x.EmailID == email));
            }
        }
Пример #7
0
 public static void RemoveUser(string id)
 {
     using (var dc = new SolutionsOnlineSellingEntities())
     {
         var item = dc.ChatUserDetail.FirstOrDefault(x => x.ConnectionId == id);
         if (item != null)
         {
             dc.ChatUserDetail.Remove(item);
             dc.SaveChanges();
         }
     }
 }
Пример #8
0
 public static void AddAllMessageinCache(string userName, string message, string emailIDLoaded)
 {
     using (var dc = new SolutionsOnlineSellingEntities())
     {
         var messageDetail = new ChatMessageDetail
         {
             UserName = userName,
             Message  = message,
             EmailID  = emailIDLoaded
         };
         dc.ChatMessageDetail.Add(messageDetail);
         dc.SaveChanges();
     }
 }
Пример #9
0
        public bool RemoveCalendar(TblCalendar model)
        {
            try
            {
                using (var context = new SolutionsOnlineSellingEntities())
                {
                    context.Entry(model).State = System.Data.Entity.EntityState.Deleted;
                    context.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                Helpers.Logger.LogException(ex, true);
                return(false);
            }
        }