//Chat Page #region "Chat Page" public IActionResult Chat(UserDetailsModel model) { string mUserID = TempData["UserID"] as string; string mUsername = TempData["Username"] as string; if (mUserID != null) { model.UserID = Convert.ToInt32(mUserID); if (model.FriendList == null || model.FriendList.Count == 0) { UserDetails_adapter UserRequest = new UserDetails_adapter(); model.FriendList = UserRequest.GetFriendList(); } if (model.NewMessage == null) { model.NewMessage = new MessageModel(); } Messages_adapter MessageAdp = new Messages_adapter(model.UserID, mUsername); model.Conversation = MessageAdp.GetConversationBetweenUsers(0); TempData.Keep(); return(View("Chat", model)); } else { TempData["Username"] = null; return(RedirectToAction("Login")); } }
//[HttpPost] //public IActionResult Chat() //{ // int mUserID = Convert.ToInt32(TempData["UserID"] as string); // model.NewMessage.SentTo = 2; //Hard code Tom // Messages_adapter MessageAdp = new Messages_adapter(mUserID); // MessageAdp.SendMessagetoFriend(model.NewMessage.SentTo, model.NewMessage.Message); // TempData.Keep(); // return View(model); //} public IActionResult Message_Send(UserDetailsModel model) { int mUserID = Convert.ToInt32(TempData["UserID"] as string); string mUsername = TempData["Username"] as string; model.NewMessage.SentTo = 2; //Hard code Tom Messages_adapter MessageAdp = new Messages_adapter(mUserID, mUsername); MessageAdp.SendMessagetoFriend(model.NewMessage); TempData.Keep(); return(Chat(model)); }