/// <summary> /// 获取用户所有文章类型 /// </summary> /// <returns></returns> public static IQueryable <BlogTypes> GetAllType(string name) { BLL.BlogTypesBLL type = new BLL.BlogTypesBLL(); return(type.GetList(t => t.BlogUsersSet.UserName == name)); //.Select(t => new { Id = t.Id, TypeName = t.TypeName }) //.ToList() //.Select(t => new ModelDB.BlogTypes() { Id = t.Id, TypeName = t.TypeName }).ToList(); }
public ActionResult GetTypeBlogs(int id, string name, int?typeId) { Response.Cache.SetOmitVaryStar(true); BLL.BlogTypesBLL typebll = new BLL.BlogTypesBLL(); var type = typebll.GetList(t => t.Id == typeId && t.BlogUsersSet.UserName == name).FirstOrDefault(); Dictionary <string, object> dic = new Dictionary <string, object>(); if (type != null) { var listblog = type.Blogs.Where(t => t.IsDel == false).OrderByDescending(t => t.BlogCreateTime).Skip((id - 1) * sizePage).Take(sizePage) .Select(t => new { BlogCreateTime = t.BlogCreateTime, BlogContent = t.BlogContent, BlogTitle = t.BlogTitle, Id = t.Id, BlogReadNum = t.BlogReadNum, BlogCommentNum = t.BlogCommentNum }) .ToList() .Select(t => new ModelDB.Blogs() { Id = t.Id, BlogTitle = t.BlogTitle, BlogCreateTime = t.BlogCreateTime, BlogContent = MyHtmlHelper.GetHtmlText(t.BlogContent), BlogReadNum = t.BlogReadNum, BlogCommentNum = t.BlogCommentNum }) .ToList(); dic.Add("blog", listblog); dic.Add("type", type.TypeName); int mcount = type.Blogs.Count(); int total = (mcount / sizePage) + (mcount % sizePage > 0 ? 1 : 0); dic.Add("total", total); SetDic(dic, name); return(View(dic)); } return(View()); }
/// <summary> /// 获取用户所有文章类型 /// </summary> /// <returns></returns> public static IQueryable <BlogTypes> GetAllType(string name) { BLL.BlogTypesBLL type = new BLL.BlogTypesBLL(); return(type.GetList(t => t.BlogUsers.UserName == name)); }
public ActionResult GetTypeBlogs(int id, string name, int? typeId) { Response.Cache.SetOmitVaryStar(true); BLL.BlogTypesBLL typebll = new BLL.BlogTypesBLL(); var type = typebll.GetList(t => t.Id == typeId && t.BlogUsersSet.UserName == name).FirstOrDefault(); Dictionary<string, object> dic = new Dictionary<string, object>(); if (type != null) { var listblog = type.Blogs.Where(t => t.IsDel == false).OrderByDescending(t => t.BlogCreateTime).Skip((id - 1) * sizePage).Take(sizePage) .Select(t => new { BlogCreateTime = t.BlogCreateTime, BlogContent = t.BlogContent, BlogTitle = t.BlogTitle, Id = t.Id, BlogReadNum = t.BlogReadNum, BlogCommentNum = t.BlogCommentNum }) .ToList() .Select(t => new ModelDB.Blogs() { Id = t.Id, BlogTitle = t.BlogTitle, BlogCreateTime = t.BlogCreateTime, BlogContent = MyHtmlHelper.GetHtmlText(t.BlogContent), BlogReadNum = t.BlogReadNum, BlogCommentNum = t.BlogCommentNum }) .ToList(); dic.Add("blog", listblog); dic.Add("type", type.TypeName); int mcount = type.Blogs.Count(); int total = (mcount / sizePage) + (mcount % sizePage > 0 ? 1 : 0); dic.Add("total", total); SetDic(dic, name); return View(dic); } return View(); }