// // GET: /Search/ public ActionResult Index() { // get data from database var routes = db.Route.ToList(); // create model var model = new RouteCheckModel(); // fill routes in the given model model.routes = routes; // return model to the view return(View(model)); }
public ActionResult Index(RouteCheckModel model) { var search = (model.SearchText); var search2 = Convert.ToInt32(model.SearchText); if (String.IsNullOrEmpty(search)) { model.routes = db.Route.ToList(); } else { // run the query to get the desired results model.routes = db.Route.Where((x => x.RouteSchedule.id.Equals(search2))).ToList(); } // return model to the view return(View(model)); }