public ActionResult Index(NewViewhelper newViewhelper) { if (Session.getCurrentUser() == null) return Redirect("/admin/account/logon"); if (!SercurityServices.HasPermission((int)TypeModule.MODULE_TINTUC, Session.getCurrentUser().username, TypeAudit.Addnew) && !SercurityServices.HasPermission((int)TypeModule.MODULE_TINTUC, Session.getCurrentUser().username, TypeAudit.Edit) && !SercurityServices.HasPermission((int)TypeModule.MODULE_TINTUC, Session.getCurrentUser().username, TypeAudit.Delete)) { return Redirect("/admin/error/error403"); } saveListNew(newViewhelper); return View(); }
public ActionResult Pagging(int chanelId, int page, String direction) { gov_menu menuInfo = _cnttDB.gov_menu.Where(m => m.id == chanelId).FirstOrDefault(); if (menuInfo == null) return Redirect("/error/error404"); NewViewhelper newViewhelper = new NewViewhelper(); newViewhelper.MenuInfo = menuInfo; newViewhelper.ChanelId = chanelId; newViewhelper.Page = page; newViewhelper.Direction = direction; saveList(newViewhelper); ViewData["newViewHelper"] = newViewhelper; return View("Index"); }
public ActionResult Index(int chanelId) { gov_menu menuInfo = _cnttDB.gov_menu.Where(m => m.id == chanelId).FirstOrDefault(); if (menuInfo == null) return Redirect("/error/error404"); NewViewhelper newViewhelper = new NewViewhelper(); newViewhelper.MenuInfo = menuInfo; newViewhelper.ChanelId = chanelId; newViewhelper.Direction = null; saveList(newViewhelper); ViewData["newViewHelper"] = newViewhelper; ViewData["lstMenuChild"] = _cnttDB.gov_menu.Where(m => m.active_flg == true && m.id_parent == chanelId).ToList(); return View("Index"); }
public List<gov_news> setSearchFilter(List<gov_news> lstNew, NewViewhelper newViewhelper) { Expression<Func<gov_news, bool>> predicate = PredicateBuilder.False<gov_news>(); if (!String.IsNullOrWhiteSpace(newViewhelper.KeySearch)) { predicate = predicate.Or(d => d.title != null && d.title.ToUpper().Contains(newViewhelper.KeySearch.ToUpper())); predicate = predicate.Or(d => d.description != null && d.description.ToUpper().Contains(newViewhelper.KeySearch.ToUpper())); predicate = predicate.Or(d => d.new_content != null && d.new_content.ToUpper().Contains(newViewhelper.KeySearch.ToUpper())); lstNew = lstNew.Where(predicate.Compile()).ToList(); } if (newViewhelper.MenuFilter != 0) { lstNew = lstNew.Where(n => n.menu_id == newViewhelper.MenuFilter).ToList(); } return lstNew; }
public NewViewhelper saveList(NewViewhelper newViewhelper) { List<gov_news> lstNew = _cnttDB.gov_news.Where(n => n.menu_id == newViewhelper.ChanelId && n.active_flg == true).ToList(); int totalCount = lstNew.Count; newViewhelper.TotalCount = totalCount; if (newViewhelper.TotalCount > 0) { int totalPage = pageCalculation(totalCount, Constant.limit); newViewhelper.TotalPage = totalPage; newViewhelper.Page = pageTransition(newViewhelper.Direction, newViewhelper.Page, totalPage); newViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, newViewhelper.Page); newViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, newViewhelper.Page, newViewhelper.FirstPage); int take = Constant.limit; int skip = (newViewhelper.Page - 1) * take; newViewhelper.LstNew = lstNew.OrderByDescending(n => n.entry_datetime).Skip(skip).Take(take).ToList(); } return newViewhelper; }
public ActionResult Index(NewViewhelper newViewhelper) { var luceneNew = new LuceneSerives.LuceneNews(); var lstNew = luceneNew.Search(newViewhelper.KeySearch).ToList(); int totalCount = lstNew.Count; newViewhelper.TotalCount = totalCount; if (newViewhelper.TotalCount > 0) { int totalPage = pageCalculation(totalCount, Constant.limit); newViewhelper.TotalPage = totalPage; newViewhelper.Page = pageTransition(newViewhelper.Direction, newViewhelper.Page, totalPage); newViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, newViewhelper.Page); newViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, newViewhelper.Page, newViewhelper.FirstPage); int take = Constant.limit; int skip = (newViewhelper.Page - 1) * take; newViewhelper.LstNew = lstNew.OrderByDescending(n => n.score).Skip(skip).Take(take).ToList(); } ViewData["newViewhelper"] = newViewhelper; return View("Search"); }
public NewViewhelper saveListNew(NewViewhelper newViewhelper) { List<gov_news> lstNew = _cnttDB.gov_news.ToList(); lstNew = setSearchFilter(lstNew, newViewhelper); int totalCount = lstNew.Count; newViewhelper.TotalCount = totalCount; if (newViewhelper.TotalCount > 0) { int totalPage = pageCalculation(totalCount, Constant.limit); newViewhelper.TotalPage = totalPage; newViewhelper.Page = pageTransition(newViewhelper.Direction, newViewhelper.Page, totalPage); newViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, newViewhelper.Page); newViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, newViewhelper.Page, newViewhelper.FirstPage); int take = Constant.limit; int skip = (newViewhelper.Page - 1) * take; newViewhelper.LstNew = lstNew.OrderByDescending(n => n.entry_datetime).Skip(skip).Take(take).ToList(); } newViewhelper.LstMenu = _cnttDB.gov_menu.OrderBy(m => m.order_number).ToList(); ViewData["newViewhelper"] = newViewhelper; return newViewhelper; }
public void setSearchFilter(NewServices newServices, NewViewhelper newViewhelper) { if (!String.IsNullOrWhiteSpace(newViewhelper.KeySearch)) newServices.KeySearch = newViewhelper.KeySearch; }