Ejemplo n.º 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;
        }
Ejemplo n.º 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();
         }
     }
 }