Ejemplo n.º 1
0
        /// <summary>
        /// 公告列表
        /// </summary>
        /// <param name="type"></param>
        /// <param name="pi"></param>
        /// <param name="ps"></param>
        /// <returns></returns>
        public ActionResult NoticeList(int type = 1, int pi = 1, int ps = 10)
        {
            int           totalSize  = 0;
            List <Notice> noticeList = new List <Notice>();

            if (type == -1)///未读消息
            {
                noticeList = noticeBll.GetNotReadNoticeList(new GetNotReadNoticeListReq()
                {
                    pi     = pi,
                    ps     = ps,
                    userId = this.GetLoginUser().UserID
                }, ref totalSize);
                #region 将所有的未读消息更改为已读?
                //if (totalSize > 0)
                //{

                //}
                #endregion
            }
            else if (type == 0)//私人消息
            {
                noticeList = noticeBll.GetNoticeList(new GetNoticeListReq()
                {
                    type   = type,
                    pi     = pi,
                    ps     = ps,
                    userId = this.GetLoginUser().UserID
                }, ref totalSize);
            }
            else
            {
                noticeList = ncBase.CurrentEntities.Notice
                             .Where(n => n.Type == type)
                             .OrderByDescending(n => n.CreateTime)
                             .Skip((pi - 1) * ps)
                             .Take(ps).ToList();

                totalSize = ncBase.CurrentEntities.Notice
                            .Where(n => n.Type == type && n.Type != 0).ToList().Count;
            }
            ViewBag.TotalSize = totalSize;
            ViewBag.pi        = pi;
            ViewBag.ps        = ps;
            ViewBag.type      = type;
            if (noticeList != null)
            {
                return(View(noticeList));
            }
            return(View(new List <Notice>()));
        }