/// <summary> /// Displays all of the TopoTrailInfo GPX data files in a list and on a map for a given country with optional region filter /// </summary> public ActionResult Country(string id, string region, string sort, string tag) { var model = InitModel(); model.SelectedSort = sort; if (!String.IsNullOrWhiteSpace(region)) { var r = GeoRegionInfo.Find(region); if (r == null) { model.ErrorMessages.Add($"Invalid region: {region}"); } else { model.SelectedRegion = r; model.SelectedCountry = r.Country; model.Trails = _trailDataService.ListByRegion(r); } } else { var c = GeoCountryInfo.Find(id); if (c == null) { model.ErrorMessages.Add($"Invalid country: {id}"); } else { model.SelectedCountry = c; model.Trails = _trailDataService.ListByCountry(c); } } if (!String.IsNullOrWhiteSpace(tag)) { model.Trails = model.Trails.Where(x => !String.IsNullOrWhiteSpace(x.Keywords) && x.Keywords.ToLowerInvariant().Contains(tag.ToLowerInvariant())).ToList(); } return(View(model)); }