public async Task <IViewComponentResult> InvokeAsync(TrainingProviderSearchViewModel searchQueryModel, bool inline = false) { var model = await _tpOrchestrator.GetSearchResults(searchQueryModel); switch (model.Status) { case ProviderSearchResponseCodes.Success: return(View("../TrainingProvider/SearchResults/Default", model)); case ProviderSearchResponseCodes.ScotlandPostcode: return(View("../TrainingProvider/SearchResults/Scotland", model)); case ProviderSearchResponseCodes.WalesPostcode: return(View("../TrainingProvider/SearchResults/Wales", model)); case ProviderSearchResponseCodes.NorthernIrelandPostcode: return(View("../TrainingProvider/SearchResults/NorthernIreland", model)); case ProviderSearchResponseCodes.PostCodeInvalidFormat: case ProviderSearchResponseCodes.PostCodeTerminated: return(View("../TrainingProvider/SearchResults/NonUK", model)); default: return(Content(string.Empty)); } }
public void Setup() { _sut = new TrainingProviderSearchFilterViewModelMapper(); _resultsItemToMap = new GroupedProviderSearchResponse() { CurrentPage = 1, SearchTerms = "Terms", ShowAllProviders = true, ShowOnlyNationalProviders = true, StatusCode = ProviderSearchResponseCodes.Success, Results = new GroupedProviderSearchResults() { ActualPage = 1, Hits = new List <GroupedProviderSearchResultItem>() { }, PostCode = "Postcode", PostCodeMissing = false, ResultsToTake = 10, HasNationalProviders = true } }; _queryItemToMap = new TrainingProviderSearchViewModel() { ApprenticeshipId = "157", IsLevyPayer = false, Keywords = "words", NationalProvidersOnly = false, Page = 1, Postcode = "Postcode", ResultsToTake = 20, SortOrder = 1 }; }
public async Task <TrainingProviderSearchFilterViewModel> GetSearchFilter(TrainingProviderSearchViewModel searchQueryModel) { var results = await _mediator.Send(new GroupedProviderSearchQuery() { ApprenticeshipId = searchQueryModel.ApprenticeshipId, PostCode = searchQueryModel.Postcode, NationalProvidersOnly = searchQueryModel.NationalProvidersOnly, IsLevyPayingEmployer = searchQueryModel.IsLevyPayer }); var model = _trainingProviderSearchFilterViewModelMapper.Map(results, searchQueryModel); switch (model.Status) { case ProviderSearchResponseCodes.Success: case ProviderSearchResponseCodes.ScotlandPostcode: case ProviderSearchResponseCodes.WalesPostcode: case ProviderSearchResponseCodes.NorthernIrelandPostcode: case ProviderSearchResponseCodes.PostCodeTerminated: case ProviderSearchResponseCodes.PostCodeInvalidFormat: return(model); default: throw new Exception($"Unable to get provider search response: {results.StatusCode}"); } }
public async Task <IViewComponentResult> InvokeAsync(TrainingProviderSearchViewModel searchQueryModel, bool inline = false) { var model = await _tpOrchestrator.GetSearchFilter(searchQueryModel); switch (model.Status) { case ProviderSearchResponseCodes.Success: return(View("../TrainingProvider/SearchFilter/Default", model)); default: return(Content(string.Empty)); } }
public async Task <IViewComponentResult> InvokeAsync(string apprenticeshipId, string searchRoute = null, string cssModifier = null, bool inline = false) { var model = new TrainingProviderSearchViewModel(); if (apprenticeshipId != null) { model.ApprenticeshipId = apprenticeshipId; } if (searchRoute != null) { model.SearchRoute = searchRoute; } return(View("~/Views/Shared/Components/TrainingProvider/Search/Default.cshtml", model)); }
public async Task <IViewComponentResult> InvokeAsync(TrainingProviderSearchViewModel searchQueryModel, bool inline = false) { var apprenticeshipType = _apprenticeshipOrchestrator.GetApprenticeshipType(searchQueryModel.ApprenticeshipId); var result = await _tpOrchestrator.GetSearchResults(searchQueryModel); var model = new TrainingProviderSearchSummaryViewModel { Postcode = searchQueryModel.Postcode, TotalResults = result.TotalResults, }; switch (apprenticeshipType) { case ApprenticeshipType.Framework: var framework = await _apprenticeshipOrchestrator.GetFramework(searchQueryModel.ApprenticeshipId); model.ApprenticeshipTitle = framework.Title; model.ApprenticeshipLevel = framework.Level; break; case ApprenticeshipType.Standard: var standard = await _apprenticeshipOrchestrator.GetStandard(searchQueryModel.ApprenticeshipId); model.ApprenticeshipTitle = standard.Title; model.ApprenticeshipLevel = standard.Level; break; } switch (result.Status) { case ProviderSearchResponseCodes.ScotlandPostcode: case ProviderSearchResponseCodes.WalesPostcode: case ProviderSearchResponseCodes.NorthernIrelandPostcode: case ProviderSearchResponseCodes.PostCodeInvalidFormat: return(Content(string.Empty)); default: return(View("../TrainingProvider/SearchSummary/Default", model)); } }
public async Task <IViewComponentResult> InvokeAsync(TrainingProviderDetailQueryViewModel providerDetailsQueryModel, TrainingProviderSearchViewModel searchQueryModel, string title = "Training provider results") { if (providerDetailsQueryModel != null) { providerDetailsQueryModel.ApprenticeshipType = _apprenticeshipOrchestrator.GetApprenticeshipType(providerDetailsQueryModel.ApprenticeshipId); var model = await _tpOrchestrator.GetDetails(providerDetailsQueryModel); model.SearchQuery = providerDetailsQueryModel; return(View("../TrainingProvider/Title/Default", model.Name)); } else { var result = await _tpOrchestrator.GetSearchResults(searchQueryModel); switch (result.Status) { case ProviderSearchResponseCodes.ScotlandPostcode: return(View("../TrainingProvider/Title/Scotland")); case ProviderSearchResponseCodes.WalesPostcode: return(View("../TrainingProvider/Title/Wales")); case ProviderSearchResponseCodes.NorthernIrelandPostcode: return(View("../TrainingProvider/Title/NorthernIreland")); case ProviderSearchResponseCodes.PostCodeInvalidFormat: return(View("../TrainingProvider/Title/NonUK")); default: return(View("../TrainingProvider/Title/Default", title)); } } }
public IActionResult Search(TrainingProviderSearchViewModel model) { return(View("TrainingProvider/SearchResults", model)); }
public SearchResultsViewModel <TrainingProviderSearchResultsItem, TrainingProviderSearchViewModel> Map(GroupedProviderSearchResponse source, TrainingProviderSearchViewModel query) { source.SearchTerms = query.Postcode; var item = new SearchResultsViewModel <TrainingProviderSearchResultsItem, TrainingProviderSearchViewModel>() { LastPage = source.Results?.LastPage ?? 0, SearchQuery = query, Status = source.StatusCode }; if (source.Results != null) { item.SearchResults = source.Results.Hits?.Select(s => _providerSearchResultsItemMaper.Map(s)); item.TotalResults = source.Results.TotalResults; } return(item); }
public TrainingProviderSearchFilterViewModel Map(GroupedProviderSearchResponse item, TrainingProviderSearchViewModel searchQueryModel) { var result = new TrainingProviderSearchFilterViewModel(); result.ApprenticeshipId = searchQueryModel.ApprenticeshipId; result.Keywords = searchQueryModel.Keywords; result.SortOrder = searchQueryModel.SortOrder; result.Postcode = searchQueryModel.Postcode; result.Status = item.StatusCode; result.HasNationalProviders = item.Results?.HasNationalProviders ?? false; result.NationalProvidersOnly = searchQueryModel.NationalProvidersOnly; return(result); }