Exemple #1
0
        /// <summary>
        /// 用户空间首页
        /// </summary>          
        public ActionResult Index()
        {
            bool bwrong = false;
            //try
            //{
            UserIndexViewData viewData = new UserIndexViewData();
            int userID = GetUserID();
            //好友列表
            viewData.FriendList = (from f in CQGJ.Friend
                                   where f.MainUserID == userID
                                   select f).ToList();
            //最新留言
            viewData.MessageList = (from m in CQGJ.Message
                                    where m.ToUserID == userID
                                    orderby m.AddTime descending
                                    select m).Take(8).ToList();
            //以往班级
            viewData.ClassList = (from c in CQGJ.Classes
                                  from s in CQGJ.Student
                                  where s.Classes == c && s.User.UserID == userID //修改刘涛, status=2为开班中,3为结束
                                  select c).ToList();

            try
            {
                //班级论坛  modified by 陈 6.30
                viewData.BBSList = (from b in CQGJ.BBS
                                    join c in CQGJ.Classes
                                    on b.Classes.ClassID equals c.ClassID
                                    where c.ClassID == (from s in CQGJ.Student
                                                        where s.User.UserID == userID
                                                        select s.Classes.ClassID).FirstOrDefault()
                                    select b).ToList();
            }
            catch
            {
                viewData.BBSList = null;
            }
            return View("Index", viewData);
            //}
            //catch
            //{
            //    bwrong = true;
            //}
            //if (bwrong)
            //{
            //    return RedirectToAction("index", "home");
            //}
        }
Exemple #2
0
        /// <summary>
        /// 用户留言列表
        /// </summary>
        /// <param name="id">类型(收件箱或发件箱)</param>
        /// <param name="page">页码</param>
        /// <returns></returns>
        public ActionResult MsgList(int id, int page)
        {
            int userID = GetUserID();
            UserIndexViewData viewData = new UserIndexViewData();
            List<Message> tempList = new List<Message>();
            if (id == 1)//收件箱
            {
                tempList = (from m in CQGJ.Message
                            where m.ToUserID == userID
                            orderby m.AddTime descending
                            select m).ToList();
            }
            else//发件箱
            {
                tempList = (from m in CQGJ.Message
                            where m.FromUserID == userID
                            orderby m.AddTime descending
                            select m).ToList();
            }

            viewData.MessageList = tempList.Skip(20 * (page - 1)).Take(20).ToList();
            UrlManager urlManager = new DefaultUrlManager(tempList.Count(), 20);
            Pager pager = new Pager(urlManager);
            viewData.PagerString = pager.PagerString;
            return View("MsgList", viewData);
        }
Exemple #3
0
        /// <summary>
        /// 用户空间首页
        /// </summary>
        public void Index()
        {
            IsLogin();
            bool bwrong = false;
            //try
            //{
                UserIndexViewData viewData = new UserIndexViewData();
                int userID = GetUserID();
                //好友列表
                viewData.FriendList = (from f in CQGJ.Friend
                                       where f.MainUserID == userID
                                       select f).ToList();
                //最新留言
                viewData.MessageList = (from m in CQGJ.Message
                                        where m.ToUserID == userID || m.FromUserID == userID
                                        orderby m.AddTime descending
                                        select m).Take(10).ToList();
                //以往班级
                viewData.ClassList = (from c in CQGJ.Classes
                                      from s in CQGJ.Student
                                      where s.Classes == c && s.User.UserID == userID //修改刘涛, status=2为开班中,3为结束
                                      select c).ToList();

                string str = ConfigurationManager.AppSettings["PhotoUrl"].ToString();
                viewData.URL = str;
                //还有获取修改user 信息的action地址
                string str2 = ConfigurationManager.AppSettings["UserEditUrl"].ToString();
                viewData.UrlUserEdit = str2;

                try
                {
                    //班级论坛  modified by 陈 6.30
                    viewData.BBSList = (from b in CQGJ.BBS
                                        join  c in CQGJ.Classes
                                        on b.Classes.ClassID equals c.ClassID
                                        where c.ClassID == (from s in CQGJ.Student
                                                            where s.User.UserID == userID
                                                            select s.Classes.ClassID).FirstOrDefault()
                                        select b).ToList();
                }
                catch
                {
                    viewData.BBSList = null;
                }
                RenderView("Index", viewData);
            //}
            //catch
            //{
            //    bwrong = true;
            //}
            //if (bwrong)
            //{
            //    RedirectToAction("index", "home");
            //}
        }