public ActionResult Result(string param) { //Before starting, we would check that param is not null!! var result = TestSearchData.DogList().Where(x => string.Equals(x.PetTypeId, param, StringComparison.CurrentCultureIgnoreCase)).ToList(); StringBuilder sb = new StringBuilder(); if (result.Any()) { sb.Append($"<h2 class=\"text-success\">Found {result.Count} results for {param}</h2>"); sb.Append("<ol>"); foreach (var pet in result) { sb.Append($"<li>{pet.PetType}</li>"); } sb.Append("</ol>"); } else { sb.Append($"<h2 class=\"text-danger\">Found {result.Count} results for {param}</h2>"); } string returnValue = sb.ToString(); if (Request.IsAjaxRequest()) { return(Json(new { Confirm = true, message = $"{returnValue}" }, JsonRequestBehavior.AllowGet)); } //Ignore this part as only doing async example return(View("~/Views/AsyncExample/AsyncExample.cshtml")); }
public ActionResult SearchFormUmbraco(string q, string dummyParam) { var queryResult = TestSearchData.DogList().Where(x => string.Equals(x.PetTypeId, q, StringComparison.CurrentCultureIgnoreCase)); var model = new SearchPageSurfaceControllerViewModel { DisplaySearchResult = queryResult }; return(PartialView("~/Views/Partials/pvSurfaceSearch.cshtml", model)); }
public ActionResult SearchForm(RenderModel objModel, string q, string dummyParam) { var queryResult = TestSearchData.DogList().Where(x => string.Equals(x.PetTypeId, q, StringComparison.CurrentCultureIgnoreCase)); var model = new SearchPageRenderMvcControllerViewModel(objModel.Content) { DisplaySearchResult = queryResult }; return(CurrentTemplate(model)); }