public ActionResult Index(int page = 1, int MenuID = 0, int ModuleId = 0, string Content = "") { Utility.GetModelState(this); var types = _cache.Get(Constants.CACHE_KEY_MODULES, () => _module.GetList()); var moduleTypes = types.Where(x => x.ParentId == MenuID).ToList(); ViewBag.ModuleTypes = moduleTypes; ViewBag.MenuID = MenuID; ViewBag.ModuleId = ModuleId; ViewBag.Content = Content; TempData["_menuid"] = Utility.GetMenuId(MenuID); var sql = Sql.Builder.Append( "SELECT News.*, Modules.DisplayName FROM News JOIN Modules ON News.ModuleId = Modules.ModuleId"); sql.Append("WHERE News.ParentId = @0", MenuID); if (ModuleId != 0) { sql.Append(" AND News.ModuleId = @0", ModuleId); } if (!string.IsNullOrEmpty(Content)) { sql.Append(" AND Title LIKE @0", "%" + Content + "%"); } var model = new PageSqlModel { PageIndex = page, PageSize = Utility.PageSize, Sql = sql }; var list = _news.GetList(model); Pagination.NewPager(this, page, (int)model.Records); return(View(list)); }
public ActionResult Index(int page = 1, int MenuID = 0, int ModuleId = 0, string Content = "") { Utility.GetModelState(this); var types = _cache.Get(Constants.CACHE_KEY_MODULES, () => _module.GetList()); var moduleTypes = types.Where(x => x.ParentId == MenuID).ToList(); ViewBag.ModuleTypes = moduleTypes; ViewBag.MenuID = MenuID; ViewBag.ModuleId = ModuleId; ViewBag.Content = Content; TempData["_menuid"] = Utility.GetMenuId(MenuID); var sql = Sql.Builder.Append( "SELECT News.*, Modules.DisplayName FROM News JOIN Modules ON News.ModuleId = Modules.ModuleId"); sql.Append("WHERE News.ParentId = @0", MenuID); if (ModuleId != 0) { sql.Append(" AND News.ModuleId = @0", ModuleId); } if (!string.IsNullOrEmpty(Content)) { sql.Append(" AND Title LIKE @0", "%" + Content + "%"); } var model = new PageSqlModel { PageIndex = page, PageSize = Utility.PageSize, Sql = sql }; var list = _news.GetList(model); Pagination.NewPager(this, page, (int)model.Records); return View(list); }