public ActionResult GetImagesAll(string value) { if (value == null) { ViewBag.Reason = String.Format("{ 0}.", Resources.Translations.YouDidNotEnterAnything);; return(View("Error")); } string searchingValue = value.Trim(); int hitsLimit = 100; var postcardWithNames = PostcardSearcher.Search(value, "Name", hitsLimit). ToList(); if (postcardWithNames.Count >= hitsLimit) { return(View(postcardWithNames)); } PostcardComparer comparer = new PostcardComparer(); var postcardWithHastTag = GetPostcardsWithTag(searchingValue); var postcardWithComments = GetPostcardsWithComments(searchingValue); var uniquePostcards = postcardWithHastTag.Union(postcardWithComments, comparer).Union(postcardWithNames, comparer); ViewBag.SearchingValue = value; return(View(uniquePostcards)); }
public JsonResult GetPostcardsPage(string userId, int?pageSize, int?postcardPage) { if (userId == null || pageSize == null || pageSize == 0 || postcardPage == null) { return(Json(null, JsonRequestBehavior.AllowGet)); } int postcardsToSkip = postcardPage.Value * pageSize.Value; var result = PostcardSearcher.Search(userId, "OwnerId").Skip(postcardsToSkip). Take(pageSize.Value).Select(p => new { databaseId = p.Id, imageUrl = p.ImageUrl, jsonPath = p.JsonPath, name = p.Name }); return(Json(result, JsonRequestBehavior.AllowGet)); }