//allows users to search for bootcamps in URL i.e. futurecodr.com/home/technolgy/ruby-on-rails public ActionResult Technology(string id) { HomeIndexViewModel model; //parse the id string and get the technology's id string name = id.Replace("-", " "); int? technologyIdByName = _technologyRepo.GetTechnologyIdByName(name); //if it does not exist, send user back to home page if (id == null) { RedirectToAction("Index"); } //otherwise, filter based on technology model = new HomeIndexViewModel { Bootcamps = FilterBootcamps(new SearchParams { SelectedTechnologyId = technologyIdByName}) }; //repopulate drop down search boxes, passing in searched-for technology model.SearchParams.Populate(_locationRepo.GetAllLocations(), _technologyRepo.GetAllTechnologies()); model.SearchParams.SelectedTechnologyId = technologyIdByName; return View("Index", model); }
public ActionResult Index(HomeIndexViewModel model) { model.Bootcamps = FilterBootcamps(model.SearchParams); model.SearchParams.Populate(_locationRepo.GetAllLocations(), _technologyRepo.GetAllTechnologies()); return View(model); }
//users can search using URL i.e. http://www.futurecodr/home/location/houston public ActionResult Location(string id) { //parse the id and get the correct locationId string city = id.Replace("-", " "); int? locationIDByCity = _locationRepo.GetLocationIDByCity(city); //if the city does not exist, send user back to home page if (id == null) { return RedirectToAction("Index"); } //if it does, filter based on city var model = new HomeIndexViewModel { Bootcamps = FilterBootcamps(new SearchParams { SelectedLocationId = locationIDByCity}) }; //repopulate drop down lists with the city passed in model.SearchParams.Populate(_locationRepo.GetAllLocations(), _technologyRepo.GetAllTechnologies()); model.SearchParams.SelectedLocationId = locationIDByCity; return View("Index", model); }
public ActionResult Index() { var model = new HomeIndexViewModel(); //cycle through each bootcamp foreach (FutureCodr.Models.Bootcamp bootcamp in _bootcampRepo.GetAllBootcamps()) { //convert each into correct format for view model and add to model FutureCodr.UI.Models.Home.Bootcamp item = ConvertBootcampFormat(bootcamp); model.Bootcamps.Add(item); } //populate search dropdowns with all locations, technologies, and price ranges model.SearchParams.Populate(_locationRepo.GetAllLocations(), _technologyRepo.GetAllTechnologies()); return View(model); }