public ActionResult Index(SlideHomeViewhelper slideHomeViewhelper) { if (Session.getCurrentUser() == null) return Redirect("/admin/account/logon"); if (!SercurityServices.HasPermission((int)TypeModule.MODULE_TINTUC, Session.getCurrentUser().username, TypeAudit.SlideTrangChu)) { return Redirect("/admin/error/error403"); } saveData(slideHomeViewhelper); return View(); }
public List<gov_slide_home> setSearchFilter(List<gov_slide_home> lstSlideHome, SlideHomeViewhelper slideHomeViewhelper) { Expression<Func<gov_slide_home, bool>> predicate = PredicateBuilder.False<gov_slide_home>(); if (!String.IsNullOrWhiteSpace(slideHomeViewhelper.KeySearch)) { predicate = predicate.Or(d => d.link != null && d.link.ToUpper().Contains(slideHomeViewhelper.KeySearch.ToUpper())); predicate = predicate.Or(d => d.description != null && d.description.ToUpper().Contains(slideHomeViewhelper.KeySearch.ToUpper())); predicate = predicate.Or(d => d.update_username != null && d.update_username.ToUpper().Contains(slideHomeViewhelper.KeySearch.ToUpper())); lstSlideHome = lstSlideHome.Where(predicate.Compile()).ToList(); } return lstSlideHome; }
public SlideHomeViewhelper saveData(SlideHomeViewhelper slideHomeViewhelper) { List<gov_slide_home> lstSlideHome = _cnttDB.gov_slide_home.ToList(); lstSlideHome = setSearchFilter(lstSlideHome, slideHomeViewhelper); int totalCount = lstSlideHome.Count; slideHomeViewhelper.TotalCount = totalCount; if (slideHomeViewhelper.TotalCount > 0) { int totalPage = pageCalculation(totalCount, Constant.limit); slideHomeViewhelper.TotalPage = totalPage; slideHomeViewhelper.Page = pageTransition(slideHomeViewhelper.Direction, slideHomeViewhelper.Page, totalPage); slideHomeViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, slideHomeViewhelper.Page); slideHomeViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, slideHomeViewhelper.Page, slideHomeViewhelper.FirstPage); int take = Constant.limit; int skip = (slideHomeViewhelper.Page - 1) * take; slideHomeViewhelper.LstSlideHome = lstSlideHome.OrderBy(u => u.order_number).Skip(skip).Take(take).ToList(); } ViewData["slideHomeViewhelper"] = slideHomeViewhelper; return slideHomeViewhelper; }