public ActionResult Listing(string DistrictDropDownList, string PropertyTypeDropDownList, string ListTypeDropDownList, string PriceDropDownList, string Search) { // Save dropdownlist options to TempData TempData["districtOption"] = DistrictDropDownList; TempData["propertyTypeOption"] = PropertyTypeDropDownList; TempData["listingTypeOption"] = ListTypeDropDownList; TempData["priceOption"] = PriceDropDownList; IEnumerable <Property> properties; // If search parameters not set if (String.IsNullOrWhiteSpace(Search)) { properties = propertyMapper.SelectAll(); // Filter for all properties } else { properties = propertyMapper.SearchAll(Search); // Filter for searched properties } // Filtering logic if (!DistrictDropDownList.Equals(defaultListOption)) { properties = properties.Where(p => p.DistrictID.Equals(propertyMapper.GetDistrictIdByDistrictName(DistrictDropDownList).First())); } if (!PropertyTypeDropDownList.Equals(defaultListOption)) { properties = properties.Where(p => p.PropertyType.Equals(PropertyTypeDropDownList)); } if (!ListTypeDropDownList.Equals(defaultListOption)) { properties = properties.Where(p => p.ListingType.Equals(ListTypeDropDownList)); } try { int price = Int32.Parse(PriceDropDownList); if (price != 0) { properties = properties.Where(p => p.AgreedPrice < price); } } catch (FormatException e) { Console.WriteLine(e.Message); } // TempData to send back to Listing page for display TempData["result_set"] = properties; if (String.IsNullOrWhiteSpace(Search)) { return(RedirectToAction("Listing")); } else { return(RedirectToAction("Listing", new { search = Search })); } }