public ActionResult AdminLoggedIn(int?page) { var entities = new Job_Candidate_Application_Entities(); var model = from r in entities.Tbl_Users select r; int pageSize = 3; int pageNum = (page ?? 1); AdminLoggedInViewModel viewModel = new AdminLoggedInViewModel(); // string userName = User.Identity.Name; //viewModel.recJobs = getRecommendedJobs(userName, viewModel); if (viewModel.numPagesRecUsers == 0) { var userentities = new Job_Candidate_Application_Entities(); IList <Tbl_Users> mylist = userentities.Tbl_Users.ToList(); //var sixRandomFoos = mylist.OrderBy(x => Guid.NewGuid()).Take(6); viewModel.recUsers = mylist; } if (User.Identity.IsAuthenticated) { viewModel.pagedList = model.OrderBy(p => p.User_Last_Name).ToPagedList(pageNum, pageSize); return(View(viewModel)); } else { return(RedirectToAction("Login", "User")); } }
public ActionResult SearchUsers(View_Models.AdminLoggedInViewModel user) { AdminLoggedInViewModel viewModel = new AdminLoggedInViewModel(); string fname = user.Fname; string lname = user.Lname; string Email = user.Email; int pageSize = 3; var entities = new Job_Candidate_Application_Entities(); var model = from r in entities.Tbl_Users where (r.User_First_Name == fname) && (r.User_Last_Name == lname) && (r.Email_Id == Email) select r; if (fname != null && lname != null && Email != null) { model = from r in entities.Tbl_Users where (r.User_First_Name == fname) && (r.User_Last_Name == lname) && (r.Email_Id == Email) select r; } else if (fname != null && lname != null && Email == null) { model = from r in entities.Tbl_Users where (r.User_First_Name == fname) && (r.User_Last_Name == lname) select r; } else if (fname != null && lname == null && Email != null) { model = from r in entities.Tbl_Users where (r.User_First_Name == fname) && (r.Email_Id == Email) select r; } else if (fname == null && lname != null && Email != null) { model = from r in entities.Tbl_Users where (r.User_Last_Name == lname) && (r.Email_Id == Email) select r; } else if (fname != null && lname == null && Email == null) { model = from r in entities.Tbl_Users where (r.User_First_Name == fname) select r; } else if (fname == null && lname != null && Email == null) { model = from r in entities.Tbl_Users where (r.User_Last_Name == lname) select r; } else if (fname == null && lname == null && Email != null) { model = from r in entities.Tbl_Users where (r.Email_Id == Email) select r; } else { return(RedirectToAction("SearchUsersFailed", "User")); } if (User.Identity.IsAuthenticated) { viewModel.pagedList = model.OrderBy(p => p.User_Last_Name).ToPagedList(1, pageSize); if (viewModel.pagedList.Count() > 0) { return(View(viewModel)); } else { return(RedirectToAction("SearchUsersFailed", "User")); } } else { return(RedirectToAction("Login", "User")); } }