public ActionResult Index(string IdOrName) { using (UserM user = new UserM()) { int uid; bool isNumeric = int.TryParse(IdOrName, out uid); if (isNumeric == true) { return(View(user.GetByIdNum(uid).ToList())); } else if (isNumeric == false && IdOrName != null && IdOrName != "") { return(View(user.GetbyName(IdOrName).ToList())); } return(View(user.GetAll().ToList())); } }