Exemplo n.º 1
0
 /// <summary>
 /// 次级页面
 /// </summary>
 /// <param name="id"></param>
 public void Category(int? id , int? page)
 {
     if (id != null && page != null)
     {
         HomeCategoryViewData viewData = new HomeCategoryViewData();
         //下一部分代码
         viewData.sigColumn = (from c in CQGJ.Column
                               where c.ColumnID == id
                               select c).First();
         viewData.lsHotNews = (from hn in CQGJ.News
                               where hn.IsNotify==false && hn.IsApproval==true && hn.Status==(int?)NewsStatus.Approved
                               orderby hn.PubDate descending
                               select hn).Take(5).ToList();
         viewData.lsCountNews = (from cn in CQGJ.News
                                 where cn.IsNotify == false && cn.IsApproval == true && cn.Status == (int?)NewsStatus.Approved
                                 orderby cn.ViewNum descending
                                 select cn).Take(5).ToList();
         //需要对lsNews进行分页
         var tempList = (from n in CQGJ.News
                         from nc in n.NewsColumn
                         where nc.Column.ColumnID == id && n.IsApproval == true && n.IsNotify == false && n.Status == (int?)NewsStatus.Approved
                         orderby n.PubDate descending
                         select n);
         //截取
         viewData.lsNews = tempList.Skip(20 * (page.Value - 1)).Take(20).ToList();
         UrlManager urlManager = new DefaultUrlManager(tempList.Count(),20);
         Pager pager = new Pager(urlManager);
         viewData.PagerString = pager.PagerString;
         RenderView("Category", viewData);
     }
     else
     {
         RedirectToAction("Index");
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 文章显示
        /// </summary>
        /// <param name="id"></param>
        public void Article(int? id)
        {
            if (id == null)
            {
                RedirectToAction("Index");
            }
            HomeCategoryViewData viewData = new HomeCategoryViewData();
            viewData.lsHotNews = (from hn in CQGJ.News
                                  where hn.IsNotify == false && hn.IsApproval == true && hn.Status == (int?)NewsStatus.Approved
                                  orderby hn.PubDate descending
                                  select hn).Take(5).ToList();
            viewData.lsCountNews = (from cn in CQGJ.News
                                    where cn.IsNotify == false && cn.IsApproval == true && cn.Status == (int?)NewsStatus.Approved
                                    orderby cn.ViewNum descending
                                    select cn).Take(5).ToList();
             News sigNews = (from n in CQGJ.News
                                where n.NewsID == id
                                select n).First();
             if (sigNews.ViewNum == null)
             {
                 sigNews.ViewNum = 1;
             }
             else
             {
                 sigNews.ViewNum += 1;

             }
             CQGJ.SaveChanges();
             viewData.sigNews = sigNews;
             //取得首页进入次级页面article的Column

             viewData.sigColumn = (from c in CQGJ.Column
                                   from nc in CQGJ.NewsColumn
                                   where nc.News.NewsID == id && nc.Column.ColumnID == c.ColumnID
                                   select c).First();
             RenderView("Article",viewData);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 网站-侧栏组件
        /// </summary>
        public ActionResult Sidebar()
        {
            HomeCategoryViewData viewData = new HomeCategoryViewData();

            viewData.lsHotNews = (from hn in CQGJ.News
                                  where hn.IsNotify == false && hn.IsApproved == true && hn.Status == (int?)NewsStatus.Approved
                                  orderby hn.PubDate descending
                                  select hn).Take(6).ToList();
            viewData.lsCountNews = (from cn in CQGJ.News
                                    where cn.IsNotify == false && cn.IsApproved == true && cn.Status == (int?)NewsStatus.Approved
                                    orderby cn.ViewNum descending
                                    select cn).Take(5).ToList();
            return View(viewData);
        }
Exemplo n.º 4
0
 //公告通知列表
 public ActionResult NoticeList(int page)
 {
     if (page > 0)
     {
         HomeCategoryViewData viewData = new HomeCategoryViewData();
         viewData.lsHotNews = (from hn in CQGJ.News
                               where hn.IsNotify == false && hn.IsApproved == true && hn.Status == (int?)NewsStatus.Approved
                               orderby hn.PubDate descending
                               select hn).Take(5).ToList();
         viewData.lsCountNews = (from cn in CQGJ.News
                                 where cn.IsNotify == false && cn.IsApproved == true && cn.Status == (int?)NewsStatus.Approved
                                 orderby cn.ViewNum descending
                                 select cn).Take(5).ToList();
         //需要对list进行分页
         var tempList = (from n in CQGJ.News
                         where n.IsNotify == true
                         orderby n.PubDate descending
                         select n);
         //截取
         viewData.NoticeList = 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("NoticeList", viewData);
     }
     else
     {
         return RedirectToAction("Index");
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// 公告通知详细页面
 /// </summary>
 /// <param name="id">公告通知ID</param>
 public ActionResult NoticeInfo(int id)
 {
     HomeCategoryViewData viewData = new HomeCategoryViewData();
     viewData.lsHotNews = (from hn in CQGJ.News
                           where hn.IsNotify == false && hn.IsApproved == true && hn.Status == (int?)NewsStatus.Approved
                           orderby hn.PubDate descending
                           select hn).Take(5).ToList();
     viewData.lsCountNews = (from cn in CQGJ.News
                             where cn.IsNotify == false && cn.IsApproved == true && cn.Status == (int?)NewsStatus.Approved
                             orderby cn.ViewNum descending
                             select cn).Take(5).ToList();
     News sigNews = (from n in CQGJ.News
                     where n.NewsID == id
                     select n).First();
     if (sigNews.ViewNum == null)
     {
         sigNews.ViewNum = 1;
     }
     else
     {
         sigNews.ViewNum += 1;
     }
     CQGJ.SaveChanges();
     viewData.sigNews = sigNews;
     return View("NoticeInfo", viewData);
 }