public ActionResult Index(MenuViewhelper menuViewhelper) { if (Session.getCurrentUser() == null) return Redirect("/admin/account/logon"); if (!SercurityServices.HasPermission((int)TypeModule.DANHMUC, Session.getCurrentUser().username, TypeAudit.Addnew) && !SercurityServices.HasPermission((int)TypeModule.DANHMUC, Session.getCurrentUser().username, TypeAudit.Edit) && !SercurityServices.HasPermission((int)TypeModule.DANHMUC, Session.getCurrentUser().username, TypeAudit.Delete)) { return Redirect("/admin/error/error403"); } saveListMenu(menuViewhelper); return View(); }
public List<gov_menu> setSearchFilter(List<gov_menu> lstMenu, MenuViewhelper menuViewhelper) { Expression<Func<gov_menu, bool>> predicate = PredicateBuilder.False<gov_menu>(); if (!String.IsNullOrWhiteSpace(menuViewhelper.KeySearch)) { predicate = predicate.Or(d => d.title != null && d.title.ToUpper().Contains(menuViewhelper.KeySearch.ToUpper())); predicate = predicate.Or(d => d.description != null && d.description.ToUpper().Contains(menuViewhelper.KeySearch.ToUpper())); lstMenu = lstMenu.Where(predicate.Compile()).ToList(); } return lstMenu; }
public MenuViewhelper saveListMenu(MenuViewhelper menuViewhelper) { List<gov_menu> lstMenu = _cnttDB.gov_menu.ToList(); lstMenu = setSearchFilter(lstMenu, menuViewhelper); int totalCount = lstMenu.Count; menuViewhelper.TotalCount = totalCount; if (menuViewhelper.TotalCount > 0) { int totalPage = pageCalculation(totalCount, Constant.limit); menuViewhelper.TotalPage = totalPage; menuViewhelper.Page = pageTransition(menuViewhelper.Direction, menuViewhelper.Page, totalPage); menuViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, menuViewhelper.Page); menuViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, menuViewhelper.Page, menuViewhelper.FirstPage); int take = Constant.limit; int skip = (menuViewhelper.Page - 1) * take; menuViewhelper.LstMenuModels = lstMenu.OrderBy(m => m.order_number).Skip(skip).Take(take).ToList(); } ViewData["menuViewhelper"] = menuViewhelper; return menuViewhelper; }