Esempio n. 1
0
        public void AddReadTimes(int blogId)
        {
            BlogTitle bt = db.BlogTitle.Where(b => b.Id == blogId).FirstOrDefault();

            bt.ReadTimes++;
            db.SaveChanges();
        }
Esempio n. 2
0
        /// <summary>
        /// 管理员获得详细的页面
        /// </summary>
        /// <returns></returns>
        public ActionResult AdminGetBlogDetail(int id)
        {
            BlogTitle bt = db.BlogTitle.Where(b => b.Id == id).FirstOrDefault();

            List <BlogReply> listBlogReply = db.BlogReply.Where(br => br.BlogId == id).OrderBy(b => b.CreatTime).ToList();

            ViewBag.listBlogReply = listBlogReply;

            AddReadTimes(id);

            return(View(bt));
        }
Esempio n. 3
0
        public ActionResult AddNewBlog(FormCollection form)
        {
            StudentInfo sInfo = db.StudentInfo.Where(s => s.Id == studentId).FirstOrDefault();
            BlogTitle   bt    = new BlogTitle
            {
                CreatId      = studentId,
                CreatAccount = sInfo.Account,
                TitleName    = form["TitleName"],
                CourseId     = Convert.ToInt32(form["teacher"]),
                BlogContent  = form["BlogContent"],
                CreatTime    = DateTime.Now.ToLongDateString() + DateTime.Now.ToShortTimeString(),
                ReadTimes    = 0
            };

            mHelp.Add <BlogTitle>(bt);
            return(RedirectToAction("ShowAllBolgList"));
        }