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> ViewContacts(AdvancedSearchViewModel viewModel) { if (viewModel.AccountID == 0) { viewModel.AccountID = this.Identity.ToAccountID(); } AdvancedSearchResponse <ContactAdvancedSearchEntry> response = await advancedSearchService.ViewContactsAsync(new AdvancedSearchRequest <ContactAdvancedSearchEntry>() { SearchViewModel = viewModel, AccountId = viewModel.AccountID, RoleId = this.Identity.ToRoleID(), RequestedBy = this.Identity.ToUserID(), IsAdvancedSearch = true, ViewContacts = true }); Guid guid = Guid.NewGuid(); if (response.ContactIds != null) { AddCookie("ContactsGuid", guid.ToString(), 1); var contactIds = response.ContactIds; cachingService.StoreSavedSearchContactIds(guid.ToString(), contactIds); } return(Json(new { success = true, response = guid.ToString() }, JsonRequestBehavior.AllowGet)); }