public async Task <HttpResponseMessage> RunSearch(AdvancedSearchViewModel viewModel) { if (viewModel.AccountID == 0) { viewModel.AccountID = this.AccountId; } var pageSize = ReadCookie("savedsearchpagesize"); var limit = 10; if (pageSize != null) { int.TryParse(pageSize, out limit); } AdvancedSearchResponse <ContactAdvancedSearchEntry> response = await advancedSearchService.RunSearchAsync( new AdvancedSearchRequest <ContactAdvancedSearchEntry>() { SearchViewModel = viewModel, AccountId = this.AccountId, RoleId = this.RoleId, RequestedBy = this.UserId, IsAdvancedSearch = true, Limit = limit, }); return(Request.BuildResponse(response)); }
public async Task <ActionResult> ContactsResultViewRead([DataSourceRequest] DataSourceRequest request, string aviewModel) { AdvancedSearchViewModel viewModel = JsonConvert.DeserializeObject <AdvancedSearchViewModel>(aviewModel); if (viewModel.AccountID == 0) { viewModel.AccountID = this.Identity.ToAccountID(); } var pageSize = request.PageSize; Session["AdvancedSearchVM"] = viewModel; AdvancedSearchResponse <ContactAdvancedSearchEntry> response; try { response = await advancedSearchService.RunSearchAsync(new AdvancedSearchRequest <ContactAdvancedSearchEntry>() { SearchViewModel = viewModel, AccountId = this.Identity.ToAccountID(), RoleId = this.Identity.ToRoleID(), RequestedBy = this.Identity.ToUserID(), IsAdvancedSearch = true, Limit = pageSize, PageNumber = request.Page }); } catch (Exception ex) { return(Json(new DataSourceResult { Errors = ex.Message }, JsonRequestBehavior.AllowGet)); } return(Json(new DataSourceResult { Data = (dynamic)response.SearchResult.Results, Total = (int)response.SearchResult.TotalHits }, JsonRequestBehavior.AllowGet)); }