Exemplo n.º 1
0
        //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);
        }