public ActionResult Index(FormCollection values) { var viewModel = new SearchViewModel(); if (values.GetValues("IsWalkingDistance") != null) { setFormValues(values, viewModel); } else viewModel.Styles = GetStyleListOptions(); return View(viewModel); }
private void setFormValues(FormCollection values, SearchViewModel viewModel) { var isWalkingDistance = GetIsWalkingDistanceFromForm(values); var style = GetStyleFromForm(values); //if style is null that means they dont care what they want if (style == null) style = new FoodStyleModel() { Id = 0 }; viewModel.IsWalkingDistance = isWalkingDistance; viewModel.Eateries = GetPossibleEateryList(isWalkingDistance, style); viewModel.SuggestedEatery = GetSuggestionFromList(viewModel.Eateries); viewModel.Styles = GetStyleListOptions(style); }