Example #1
0
        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");
        }