Add drop down list filter to search action

Jan 25th, 2014
DreamIt
Category:
Programming
Price: $40 USD

Question description

The following actions in a controller get the search person page and return the search person results.  At the moment, I have one drop down list filter for the country of birth, one drop down list filter for city and two other search filters by "age" and "gender". I want to add an additional drop down list filter which will allow me to search by hair colour. I am a little bit inexperienced in this area and need some help to be able to do this. 

  /// <summary>
  /// Gets the person search page.
  /// </summary>
  /// <returns>
  /// The person search page.
  /// </returns>
  /// GET: /Person/Search
  [HttpGet]
  public ActionResult Search()
  {
  return
  this.View(
  new PersonSearchViewModel
  {
CountryViewModel =
  new CountryViewModel
  {
Country =
  new SelectList(this.countryManager.GetCountries(), "Name"),
 Cities = new SelectList(new List<City>(), "Name")
  }
  });
  }

  /// <summary>
  /// Searches the person.
  /// </summary>
  /// <param name="viewModel">
  /// The <see cref="PersonSearchViewModel"/> to filter by.
  /// </param>
  /// <returns>
  /// The <see cref="ActionResult"/>.
  /// </returns>
  /// POST: /Person/Search
  [HttpPost]
  public ActionResult Search(PersonSearchViewModel viewModel)
  {
  viewModel.CountryViewModel = new CountryViewModel
  {
 Countries = new SelectList(this.countryManager.GetPCountries(), "Id", "Name"),
 Cities =
  viewModel.SearchCriteria.CountryId > 0
  ? new SelectList(
  this.countryManager.GetCitiesviewModel.SearchCriteria.CountryId.GetValueOrDefault()),
  "Id",
  "Name")
  : new SelectList(new List<City>(), "Id", "Name")
  };


  viewModel.PersonViewModel = new PersonViewModel
  {
  People = new SelectList(this.personManager.GetAllPeople)),
  };


  if (!this.ModelState.IsValid)
  {
  return this.View(viewModel);
  }

  viewModel.SearchResult = this.peopleManager.FindPeople(viewModel.SearchCriteria, 1234);

  return this.View(viewModel);


  }

Tutor Answer

(Top Tutor) Daniel C.
(997)
School: University of Maryland
PREMIUM TUTOR

Studypool has helped 1,244,100 students

5 Reviews


Summary
Quality
Communication
On Time
Value
ashleyisgod
Nov 27th, 2016
" Top quality work from this guy! I'll be back! "
Molly_Moon
Nov 5th, 2016
" AMAZING as always! "
Hemapathy
Oct 13th, 2016
" all I can say is wow very fast work, great work thanks "
BlueOcean
Sep 30th, 2016
" Awesome! Exactly what I wanted. "
kevin12622
Sep 21st, 2016
" Goes above and beyond expectations ! "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1831 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors