public void AddReadTimes(int blogId) { BlogTitle bt = db.BlogTitle.Where(b => b.Id == blogId).FirstOrDefault(); bt.ReadTimes++; db.SaveChanges(); }
/// <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)); }
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")); }