Exemplo n.º 1
0
        public JsonResult GetCategoryList(string searchTerm)
        {
            var list = _categorysService.GetAll();

            if (searchTerm != null)
            {
                list = _categorysService.SearchCategoryByName(searchTerm);
            }
            var modifiedData = list.Select(t => new
            {
                id   = t.Id,
                text = t.NameCategory
            });

            return(Json(modifiedData, JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetPageSearch(int?page)
        {
            int pageSize = VariableUtils.pageSize;

            int pageNumber = (page ?? 1);

            if (Session["KeyWordSearch"] != null)
            {
                var name            = Session["KeyWordSearch"].ToString();
                var listSearch      = _categorysService.SearchCategoryByName(name);
                var listSearchModel = AutoMapper.Mapper.Map <IEnumerable <CategorysViewModel> >(listSearch);
                return(PartialView("_PartialViewCategorys", listSearchModel.ToPagedList(pageNumber, pageSize)));
            }

            return(PartialView("_PartialViewCategorys",
                               _listCategorysViewModel.ToPagedList(pageNumber, pageSize)));
        }