/// <summary> /// 添加用户留言 /// </summary> public ActionResult AddMsg() { int userID = GetUser().UserID; UserMsgListViewData viewData = new UserMsgListViewData(); //好友列表 viewData.FriendList = (from f in CQGJ.Friend from u in CQGJ.User where f.MainUserID == userID where f.SubUserID == u.UserID select u).ToList(); if (Request.HttpMethod == "POST") { Message message = new Message(); message.Subject = GetString("Title"); message.Content = GetString("Content"); message.AddTime = DateTime.Now; message.FromUserID = userID; message.ToUserID = GetInt("ToUserID"); CQGJ.AddToMessage(message); CQGJ.SaveChanges(); return RedirectToAction("MsgList/2/1"); } return View("AddMsg", viewData); }
/// <summary> /// 添加用户留言 /// </summary> public void AddMsg() { int userID = GetUserID(); UserMsgListViewData viewData = new UserMsgListViewData(); //好友列表 viewData.FriendList = (from f in CQGJ.Friend where f.MainUserID == userID select f).ToList(); if (GetString("Title") != "") { Message message = new Message(); message.Subject = GetString("Title"); message.Content = GetString("Content"); message.AddTime = DateTime.Now; message.FromUserID = userID; message.ToUserID = GetInt("ToUserID"); CQGJ.AddToMessage(message); CQGJ.SaveChanges(); RedirectToAction("MsgList"); } RenderView("AddMsg", viewData); }
/// <summary> /// 用户留言列表 /// </summary> public void MsgList() { int userID = GetUserID(); UserMsgListViewData viewData = new UserMsgListViewData(); viewData.Messages = (from m in CQGJ.Message where m.ToUserID == userID || m.FromUserID == userID orderby m.AddTime descending select m).ToList(); RenderView("MsgList", viewData); }