public ActionResult ViewCategory(string category, int Page=1) { CategoryService service = new CategoryService(); Category cat = service.GetByStaticName(category); NewsService newsSvc = new NewsService(); string status = EntityStates.Activated.ToString(); var paged = newsSvc.GetPaged(p=>p.Status == status && p.News_CategoryID == cat.CategoryID, new IOrderByClause<News>[] {new OrderByClause<News, DateTime>(p=>p.UpdateDate.Value, SortDirection.Decending)}, Page, 20 ); ViewCategoryModel model = new ViewCategoryModel() { Category = cat, SubCategories = cat.Categories1.ToList(), LastedNewsPaged = paged, LastestNews = paged.ToList(), }; return View(model); }
public ActionResult Index(int? id, int? Page) { NewsService serivce = new NewsService(); string status = EntityStates.Activated.ToString(); NewsIndexModel model = new NewsIndexModel() { NewsItems = serivce.GetPaged(p => p.Status == status &&(id.HasValue? p.News_CategoryID== id.Value:true) , new IOrderByClause<News>[] { new OrderByClause<News, int>(p => p.NewsID, SortDirection.Decending) }, Page.HasValue ? Page.Value : 1, GMRSetting.PageSize) }; return View(model); }