public JsonResult GetGoogleCategories(string search, int?page) { page = page ?? 1; const int take = 100; var skip = (page.Value - 1) * take; var categories = _googleFeedService.GetTaxonomyList(search); var hasMoreItems = (page.Value * take) < categories.Count; //$"{skip}\\{categories.Length} {hasMoreItems}: {search.NaIfEmpty()}".Dump(); var items = categories.Select(x => new { id = x, text = x }) .Skip(skip) .Take(take) .ToList(); return(new JsonResult { Data = new { hasMoreItems, results = items }, MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult GoogleCategories() { var categories = _googleService.GetTaxonomyList(); return(Json(categories, JsonRequestBehavior.AllowGet)); }