public ActionResult Search() { this.loadViewBag(); RegisterViewModel reguser = SessionManager.GetInstance.SearchUser; IQueryable <STP_GetUserDetail> userdetails = null; if (reguser != null) { if (SessionManager.GetInstance.ActiveUser != null) { userdetails = objUser.GetUserDetailsForUser().Where(p => p.UserId != SessionManager.GetInstance.ActiveUser.UserId && p.UserType.ToUpper() != "ADMIN"); } else { userdetails = objUser.GetUserDetailsForUser().Where(p => p.UserType.ToUpper() != "ADMIN"); } SessionManager.GetInstance.SearchUser = null; } else { if (SessionManager.GetInstance.ActiveUser != null) { string gender = SessionManager.GetInstance.ActiveUser.Gender == "M" ? "F" : "M"; userdetails = objUser.GetUserDetailsForUser().Where(p => p.UserId != SessionManager.GetInstance.ActiveUser.UserId && p.Gender == gender && p.UserType.ToUpper() != "ADMIN"); } else { userdetails = objUser.GetUserDetailsForUser().Where(p => p.UserType.ToUpper() != "ADMIN"); } } var filter = userdetails.OrderBy(p => p.UserId).Skip(0 * PageSize).Take(PageSize); Session["pageindex"] = 0; Session["users"] = userdetails; return(View("Search", filter)); }