예제 #1
0
        public List<ChatObj> Post(ChatObj next)
        {
            DraftUser user = DraftAuthentication.AuthenticateRequest(Request);

            String text = next.Text;
            if (!String.IsNullOrWhiteSpace(text))
            {
                this.dataSource.SubmitChat(new ChatObj()
                {
                    Text = text.Trim(),
                    UserID = user.ID,
                    Date = DateTime.Now
                });
            }

            List<ChatObj> chatData = this.dataSource.GetChatData();

            return chatData;
        }
예제 #2
0
 public void SubmitChat(ChatObj toSubmit)
 {
     lock (_ChatLock)
     {
         var query = from u in db.Users
                     where u.UserID == toSubmit.UserID
                     select u;
         if (query.Count() == 1)
         {
             ChatRoom newChat = new ChatRoom()
             {
                 Date = toSubmit.Date,
                 Text = toSubmit.Text,
                 UserID = toSubmit.UserID
             };
             db.ChatRooms.InsertOnSubmit(newChat);
             db.SubmitChanges();
         }
     }
 }