Пример #1
0
        public ActionResult PostMessage(FormCollection collection, int chatID)
        {
            Message m = new Message();

            m.UserID   = collection["userid"];
            m.UserName = collection["username"];
            m.Text     = collection["messageText"];
            ApplicationUser a = accountService.getUserByID(m.UserID);

            m.UserProfilePic = a.ProfilePic;
            m.DateInserted   = DateTime.Now;

            Chat c = chatService.getChatByID(chatID);

            chatService.AddMessage(m);
            chatService.AddMessageToChat(c, m);

            var currMessages = chatService.GetMessagesByChat(c);

            return(Json(currMessages, JsonRequestBehavior.AllowGet));
        }