Пример #1
0
 public JsonResult ExamineMethod(int id)
 {
     try {
         model           = client.GetById(id);
         model.ifexamine = true;
         client.Update(model);
         return(Json(new { code = 0 }));
     }
     catch (Exception ex)
     {
         return(Json(new { code = 1 }));
     }
 }
Пример #2
0
        /// <summary>
        /// 详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Details(int id, int page = 1)
        {
            ViewBag.id = id;
            ViewtLearing model = client.GetById(id);

            model.iReadNums = model.iReadNums + 1;
            client.Update(model);//阅读量+1

            if (user != null)
            {
                ViewBag.NickName = user.NickName;
            }

            #region  一篇文章和下一篇文章

            //用pre和next变量分别存放上一篇文章和下一篇文章的id号
            int pre = 0, next = 0, i = 0, j;
            int retCount = 0;
            //计算总记录数
            List <ViewtLearing> listEnity = client.GetPageList_All(0, out retCount);
            ViewBag.listEnity = listEnity.Where(x => x.ifexamine == true).Take(15).ToList();
            int   num   = retCount;
            int[] a     = new int[num];
            var   query = from c in listEnity select c.ID;
            //将所有的文章id号全部放入一个数组中
            foreach (var item in query)
            {
                a[i] = Convert.ToInt32(item);
                i++;
            }
            //循环,获取上一篇和下一篇文章的ID号,分别放入变量pre和next中
            for (j = 0; j < num; j++)
            {
                if (a[j] == id)
                {
                    if (j != 0)
                    {
                        pre = a[j - 1];
                    }
                    if (j != num - 1)
                    {
                        next = a[j + 1];
                    }
                }
            }
            //获取上一篇文章的标题
            if (pre == 0)
            {
                ViewBag.preTitle = "已经是第一篇";
                ViewBag.pre      = id;
            }
            else
            {
                ViewBag.preTitle = listEnity.Where(c => c.ID == pre).Single().sTitle;
                ViewBag.pre      = pre;
            }
            //获取下一篇文章的标题
            if (next == 0)
            {
                ViewBag.nextTitle = "已经是最后一篇";
                ViewBag.next      = id;
            }
            else
            {
                ViewBag.nextTitle = listEnity.Where(c => c.ID == next).Single().sTitle;
                ViewBag.next      = next;
            }

            #endregion
            model.iZanNums = zanclient.Count(id, user.Uid, 2);
            ViewBag.learn  = model;
            int rcount   = 0;
            int pagesize = 10;
            ViewBag.MsgInfo = method.listMessage(id, 2, page, out rcount);//留言 评论
            ViewBag.rcount  = rcount;

            Webdiyer.WebControls.Mvc.PagedList <ViewtMessageGroup> l = new Webdiyer.WebControls.Mvc.PagedList <ViewtMessageGroup>(ViewBag.MsgInfo, page, pagesize, rcount);
            if (Request.IsAjaxRequest())
            {
                return(PartialView("PartialMsg", l));
            }
            return(View(l));

              
        }