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