public IPagedList <Recomment> GetPagedList(RecommentCategory category, int pageNumber, int pageSize = 36) { var query = _context.Recomments.Where(r => r.Category == category); query = query.OrderByDescending(r => r.Top).ThenByDescending(r => r.TimeStamp); return(query.ToPagedList(pageNumber, pageSize)); }
//[OutputCache(Duration = 1*60*60,VaryByParam = "id")] public ActionResult Recomment(RecommentCategory id) { var list = _recommentService.GetRecommentsByCategory(id); ViewBag.Title = id.ToString(); ViewBag.Icon = _recommentService.GetIconByCategory(id); return(PartialView(list)); }
public ActionResult Index(RecommentCategory id, int?page) { int pageNumber = page ?? 1; ViewBag.Category = (int)id; ViewBag.Title = id.ToString(); return(View(_recommentService.GetPagedList(id, pageNumber))); }
public List <Recomment> GetRecommentsByCategory(RecommentCategory category, int top = 18) { return (_context.Recomments.Where(r => r.Category == category) .OrderByDescending(r => r.Top) .ThenByDescending(r => r.TimeStamp) .Take(top) .ToList()); }
// // GET: /Recomment/ public ActionResult Manage(RecommentCategory category, string recommentTitle, int?page) { recommentTitle = recommentTitle.Trim(); int pageNumber = page ?? 1; ViewBag.RecommentTitle = recommentTitle; ViewBag.RecommentCategory = category; return(View(_recommentService.GetPagedList(category, recommentTitle, pageNumber))); }
public IPagedList <Recomment> GetPagedList(RecommentCategory category, string recommentTitle, int pageNumber, int pageSize = 20) { var query = _context.Recomments.Where(r => r.Category == category); if (!string.IsNullOrWhiteSpace(recommentTitle)) { query = query.Where(c => c.Title.Contains(recommentTitle)); } query = query.OrderByDescending(r => r.TimeStamp); return(query.ToPagedList(pageNumber, pageSize)); }
public string GetIconByCategory(RecommentCategory category) { switch (category) { case RecommentCategory.剧集: return("fa-tv"); case RecommentCategory.动漫: return("fa-modx"); case RecommentCategory.图书: return("fa-book"); case RecommentCategory.教育: return("fa-graduation-cap"); case RecommentCategory.日剧: return("fa-ge"); case RecommentCategory.游戏: return("fa-gamepad"); case RecommentCategory.电影: return("fa-film"); case RecommentCategory.综艺: return("fa-birthday-cake"); case RecommentCategory.美剧: return("fa-medium"); case RecommentCategory.资料: return("fa-file-text-o"); case RecommentCategory.软件: return("fa-windows"); case RecommentCategory.韩剧: return("fa-codiepie"); case RecommentCategory.音乐: return("fa-music"); default: return("fa-chrome"); } }