Пример #1
0
 public string[] GetMessages()
 {
     using (var context = new ChatContext())
     {
         return context.ChatMsg.OrderByDescending(c => c.TimeStamp)
             .Take(10)
             .OrderBy(c => c.TimeStamp).Select(c => c.Message)
             .ToArray();
     }
 }
Пример #2
0
 public string[] GetMessages()
 {
     using (var context = new ChatContext())
     {
         return(context.ChatMsg.OrderByDescending(c => c.TimeStamp)
                .Take(10)
                .OrderBy(c => c.TimeStamp).Select(c => c.Message)
                .ToArray());
     }
 }
Пример #3
0
        public string[] SendMessage(string message)
        {
            using (var context = new ChatContext())
            {
                context.ChatMsg.Add(new ChatMsg()
                {
                    Message = message,
                    TimeStamp = DateTime.Now,
                    User = "******"
                });

                context.SaveChanges();
                return GetMessages();
            }
        }
        public Message[] SendMessage(Message message)
        {
            using (var context = new ChatContext())
            {
                context.ChatMsg.Add(new ChatMsg()
                {
                    Message = message.Content,
                    TimeStamp = DateTime.Now,
                    User = message.User
                });

                context.SaveChanges();
                return GetMessages();
            }
        }
        public Message[] SendMessage(Message message)
        {
            using (var context = new ChatContext())
            {
                context.ChatMsg.Add(new ChatMsg()
                {
                    Message   = message.Content,
                    TimeStamp = DateTime.Now,
                    User      = message.User
                });

                context.SaveChanges();
                return(GetMessages());
            }
        }
        public string[] SendMessage(string message)
        {
            using (var context = new ChatContext())
            {
                context.ChatMsg.Add(new ChatMsg()
                {
                    Message   = message,
                    TimeStamp = DateTime.Now,
                    User      = "******"
                });

                context.SaveChanges();
                return(GetMessages());
            }
        }