Ejemplo n.º 1
0
        //文章详细页
        public ActionResult Article(int?id)
        {
            if (!id.HasValue || id.Value <= 0)
            {
                return(Redirect("/Error/E404/"));
            }
            var model = service.Get(id.Value);

            if (model == null)
            {
                return(Redirect("/Error/E404/"));
            }

            List <CategoryListItem> catelist = service.CategoriesItem();

            ViewBag.Categies         = catelist;
            ViewBag.ReadHotList      = service.ReadHotList();
            ViewBag.SameCateArticles = service.TheSameCategoryArticles(model.CategoryId, id.Value); //相关文章
            ViewBag.Comments         = service.Comments(id.Value);                                  //文章最新评论列表

            ArticleClickCookie.AddClick(id.Value, service.AddClickSuccess);

            string cateName = catelist != null?catelist.Where(c => c.Id == model.CategoryId).Select(c => c.Name).FirstOrDefault() : "";

            ViewBag.Title       = string.Format("{0} - {1}", model.Title, cateName);
            ViewBag.Description = model.Summary;
            ViewBag.Keywords    = string.Format("{0} {1}", model.Keys, cateName);

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Details(int?id)
        {
            if (!id.HasValue || id.Value <= 0)
            {
                return(Redirect("/Error/E404/"));
            }
            var model = service.Get(id.Value);

            if (model == null)
            {
                return(Redirect("/Error/E404/"));
            }

            if (model.CategoryId > 0)
            {
                var cateModel = service.GetCategory(model.CategoryId);
                if (cateModel != null)
                {
                    model.CategoryName = cateModel.Name;
                }
            }
            else
            {
                model.CategoryName = "文章";
            }
            ViewBag.Comments = service.Comments(id.Value);//文章最新评论列表

            ArticleClickCookie.AddClick(id.Value, service.AddClickSuccess);

            ViewBag.Title       = string.Format("{0} - {1}", model.Title, model.CategoryName);
            ViewBag.Description = model.Summary;
            ViewBag.Keywords    = string.Format("{0} {1}", model.Keys, model.CategoryName);

            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult Comments()
        {
            int page        = CommonCs.GetObjToInt(Request.Params["page"]);
            int pageCount   = 30;
            int recordCount = 0;

            ViewBag.Comments = service.Comments(page, pageCount, out recordCount);
            ViewBag.PageHtml = CommonCs.GetPageHtmlStr(recordCount, pageCount, page, 8, "/Article/Comments/", "");
            ViewBag.CurrUrl  = string.Format("/Article/Comments?page={0}", page);
            return(View());
        }