public static SelectList GetSortTypes(VacancySearchSortType selectedSortType = VacancySearchSortType.Distance, string keywords = null, bool isLocalLocationType = true) { var sortTypeOptions = new ArrayList(); if (!string.IsNullOrWhiteSpace(keywords)) { sortTypeOptions.Add(new { SortType = VacancySearchSortType.Relevancy, Name = "Best match" }); } sortTypeOptions.Add(new { SortType = VacancySearchSortType.ClosingDate, Name = "Closing date" }); if (isLocalLocationType) { sortTypeOptions.Add(new { SortType = VacancySearchSortType.Distance, Name = "Distance" }); } sortTypeOptions.Add(new { SortType = VacancySearchSortType.RecentlyAdded, Name = "Recently added" }); var sortTypes = new SelectList( sortTypeOptions, "SortType", "Name", selectedSortType ); return(sortTypes); }
public void ChangeLocationTypeOnNationalSearchWithoutKeywords() { const VacancySearchSortType originalSortType = VacancySearchSortType.Distance; var searchViewModel = new ApprenticeshipSearchViewModel { Location = ACityWithOneSuggestedLocation, LocationType = ApprenticeshipLocationType.National, SortType = originalSortType, SearchAction = SearchAction.LocationTypeChanged }; var response = Mediator.Results(searchViewModel); response.AssertCode(ApprenticeshipSearchMediatorCodes.Results.Ok, true); response.ViewModel.VacancySearch.SortType.Should().Be(VacancySearchSortType.ClosingDate); }
public void SortWithKeywords() { const VacancySearchSortType originalSortType = VacancySearchSortType.Distance; var searchViewModel = new ApprenticeshipSearchViewModel { Location = ACityWithOneSuggestedLocation, LocationType = ApprenticeshipLocationType.NonNational, SortType = originalSortType, SearchAction = SearchAction.Sort, Keywords = AKeyword }; var response = Mediator.Results(null, searchViewModel); response.AssertCode(ApprenticeshipSearchMediatorCodes.Results.Ok, true); response.ViewModel.VacancySearch.SortType.Should().Be(originalSortType); }
public void FromSearchUrlParseTests( ApprenticeshipLevel apprenticeshipLevel, string keywords, double latitude, double longitude, string location, ApprenticeshipLocationType locationType, int pageNumber, SearchAction searchAction, string searchField, ApprenticeshipSearchMode searchMode, VacancySearchSortType searchSortType, int withinDistance, string category, string[] subCategories, string url) { var searchViewModel = ApprenticeshipSearchViewModel.FromSearchUrl(url); searchViewModel.Should().NotBeNull(); searchViewModel.ApprenticeshipLevel.Should().Be(apprenticeshipLevel.ToString()); searchViewModel.Keywords.Should().Be(keywords); searchViewModel.Latitude.Should().Be(latitude); searchViewModel.Longitude.Should().Be(longitude); searchViewModel.Location.Should().Be(location); searchViewModel.LocationType.Should().Be(locationType); searchViewModel.PageNumber.Should().Be(1); searchViewModel.ResultsPerPage.Should().Be(5); searchViewModel.SearchAction.Should().Be(searchAction); searchViewModel.SearchField.Should().Be(searchField); searchViewModel.SearchMode.Should().Be(searchMode); searchViewModel.SortType.Should().Be(searchSortType); searchViewModel.WithinDistance.Should().Be(withinDistance); searchViewModel.Category.Should().Be(category); searchViewModel.SubCategories.ShouldAllBeEquivalentTo(subCategories); }
public ApprenticeshipSearchViewModelBuilder WithSortType(VacancySearchSortType sortType) { _sortType = sortType; return(this); }