public ActionResult IndustryJobAds(string industrySegment) { var industry = _industriesQuery.GetIndustryByUrlSegment(industrySegment, JobAdsRoutes.SegmentSuffix); if (industry == null) { return(RedirectToUrl(JobAdsRoutes.BrowseJobAds.GenerateUrl(), true)); } // Check the url. var result = EnsureUrl(industry.GenerateJobAdsUrl()); if (result != null) { return(result); } // Return the view for this industry. var country = ActivityContext.Location.Country; return(View(new LocationsJobAdsModel { Industry = industry, CountrySubdivisions = _locationQuery.GetCountrySubdivisions(country).Where(s => !s.IsCountry).ToList(), Regions = _locationQuery.GetRegions(country), })); }
private ActionResult LocationIndustryJobAds(string locationSegment, string industrySegment, int?page) { var industry = _industriesQuery.GetIndustryByUrlSegment(industrySegment, JobAdsRoutes.SegmentSuffix); var location = _locationQuery.GetLocationByUrlSegment(ActivityContext.Location.Country, locationSegment, JobAdsRoutes.SegmentSuffix); if (industry == null && location == null) { return(RedirectToUrl(JobAdsRoutes.BrowseJobAds.GenerateUrl(), true)); } if (location == null) { return(RedirectToUrl(industry.GenerateJobAdsUrl(), true)); } if (industry == null) { return(RedirectToUrl(location.GenerateJobAdsUrl(), true)); } // Check url. var result = EnsureUrl(location.GenerateJobAdsUrl(industry, page)); if (result != null) { return(result); } if (page.HasValue && page.Value < 2) { //on page 0 or 1; should be page <blank> return(RedirectToUrl(location.GenerateJobAdsUrl(industry, null), true)); } //construct a criteria and presentation and return results var criteria = new JobAdSearchCriteria { Location = _locationQuery.ResolveLocation(ActivityContext.Location.Country, location.Name), IndustryIds = new List <Guid> { industry.Id }, SortCriteria = new JobAdSearchSortCriteria { ReverseSortOrder = false, SortOrder = JobAdSortOrder.CreatedTime }, }; var presentation = new JobAdsPresentationModel { Pagination = new Pagination { Page = page.HasValue ? page : 1 }, }; criteria.PrepareCriteria(); PreparePresentationModel(presentation); var browseList = Browse(CurrentMember, criteria, presentation, JobAdListType.BrowseResult); if ((browseList.Results.TotalJobAds <= (presentation.Pagination.Page - 1) * Reference.DefaultItemsPerPage) && presentation.Pagination.Page > 1) { //on some page that doesn't exist (anymore) - redirect to page one return(RedirectToUrl(location.GenerateJobAdsUrl(industry, null))); } browseList.Industry = industry; browseList.Location = location; return(View("Results", browseList)); }