public ActionResult Index(string searchText, int?pageNumber) { List <Library.User> users = userWeb.GetUsers() .Where(x => !x.Delete).ToList(); //if (SessionManagement.LoginUser.UserClass == 2) //{ // //return View(users); // IPagedList<User> userWebPagedList = users.ToPagedList(pageNumber ?? 1, 10); // return View(userWebPagedList); //} if (SessionManagement.LoginUser != null && SessionManagement.LoginUser.UserClass == 2) { if (searchText != null) { List <Library.User> model2 = userWeb.GetUsers() .Where(x => !x.Delete && x.UserName.Contains(searchText) || searchText == null).ToList(); //.Where(x => x.UserName.Contains(searchText) || searchText == null && !x.Delete ).ToList(); IPagedList <User> userWebPagedList = model2.ToPagedList(pageNumber ?? 1, 5); return(View(userWebPagedList)); } else { //return View(users); IPagedList <User> userWebPagedList = users.ToPagedList(pageNumber ?? 1, 10); return(View(userWebPagedList)); } } else { return(RedirectToAction("Index", "Message")); } }
public ActionResult Index() { List <Library.User> users = userWeb.GetUsers() .Where(x => !x.Delete) .ToList(); byte UserClass = 0; if (Session["Id"] != null) { byte.TryParse(Session["UserClass"].ToString(), out UserClass); } if (UserClass == 2) { return(View(users)); } else { return(RedirectToAction("Index", "Message")); } }