public ActionResult Index(string searchQuery, string searchScope, int? pageNumber, int pageSize = 12) { int id = WebSecurity.GetUserId(WebSecurity.CurrentUserName); var userProfile = _userContext.UserProfiles.First(x => x.UserId == id); searchScope = "all"; if (string.IsNullOrWhiteSpace(userProfile.PrivateKey) || string.IsNullOrWhiteSpace(userProfile.PublicKey)) { TempData["Notification"] = new Notification("Please provide access keys that have been sent you by email", Nature.warning); return RedirectToAction("Settings", "Account"); } pageNumber = pageNumber ?? 1; ContactEndpoint c = new ContactEndpoint(); UserData userData = new UserData(); userData.PublicKey = userProfile.PublicKey; userData.Timestamp = DateTime.Now; List<Contact> result; if (string.IsNullOrWhiteSpace(searchQuery) || searchScope == null) { userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/" + pageNumber.Value + "/" + pageSize+"/false" + userData.Timestamp + userProfile.PrivateKey); result = c.GetContacts(pageNumber.Value, pageSize, userData); } else { userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/"+searchScope+"/"+searchQuery+"/" + pageNumber.Value + "/" + pageSize+"/false" + userData.Timestamp + userProfile.PrivateKey); result = c.GetFilteredContacts(searchScope, searchQuery, pageNumber.Value, pageSize, userData); } ViewBag.SearchQuery = searchQuery; return View(result); }