diff --git a/LearningHub.Nhs.WebUI/Models/Search/SearchResultViewModel.cs b/LearningHub.Nhs.WebUI/Models/Search/SearchResultViewModel.cs index e17f3c851..543a50e5f 100644 --- a/LearningHub.Nhs.WebUI/Models/Search/SearchResultViewModel.cs +++ b/LearningHub.Nhs.WebUI/Models/Search/SearchResultViewModel.cs @@ -88,5 +88,10 @@ public class SearchResultViewModel /// Gets or sets Suggested Catalogue name. /// public string SuggestedCatalogue { get; set; } + + /// + /// Gets or sets Suggested Resource name. + /// + public string SuggestedResource { get; set; } } } diff --git a/LearningHub.Nhs.WebUI/Services/SearchService.cs b/LearningHub.Nhs.WebUI/Services/SearchService.cs index 45b7f4276..9fc4aab5a 100644 --- a/LearningHub.Nhs.WebUI/Services/SearchService.cs +++ b/LearningHub.Nhs.WebUI/Services/SearchService.cs @@ -64,6 +64,7 @@ public async Task PerformSearch(IPrincipal user, SearchRe var groupId = Guid.Parse(searchRequest.GroupId); bool didYouMeanEnabled = false; var suggestedCatalogue = string.Empty; + var suggestedResource = string.Empty; var resourceSearchPageSize = this.settings.FindwiseSettings.ResourceSearchPageSize; var catalogueSearchPageSize = this.settings.FindwiseSettings.CatalogueSearchPageSize; @@ -125,6 +126,7 @@ public async Task PerformSearch(IPrincipal user, SearchRe if (resourceResult?.Spell?.Suggestions?.Count > 0) { resourceSearchRequestModel.SearchText = Regex.Replace(resourceResult?.Spell?.Suggestions?.FirstOrDefault().ToString(), "<.*?>", string.Empty); + suggestedResource = resourceSearchRequestModel.SearchText; // calling findwise endpoint with new search text - resources resourceResultTask = this.GetSearchResultAsync(resourceSearchRequestModel); @@ -233,6 +235,7 @@ public async Task PerformSearch(IPrincipal user, SearchRe }, DidYouMeanEnabled = didYouMeanEnabled, SuggestedCatalogue = suggestedCatalogue, + SuggestedResource = suggestedResource, }; return searchResultViewModel; diff --git a/LearningHub.Nhs.WebUI/Views/Search/Index.cshtml b/LearningHub.Nhs.WebUI/Views/Search/Index.cshtml index eb76017f6..4b8e0e6e3 100644 --- a/LearningHub.Nhs.WebUI/Views/Search/Index.cshtml +++ b/LearningHub.Nhs.WebUI/Views/Search/Index.cshtml @@ -9,15 +9,18 @@ }
-
-

- Search results @(!string.IsNullOrEmpty(Model.SearchString) ? "for " + Model.SearchString : string.Empty) -

+
@if (Model.DidYouMeanEnabled) { -
- We couldn't find a match for @(Model.SearchString), try adjusting your search terms or explore the suggestions below. -
+

+ No results were found for @(Model.SearchString) please change your search term or explore the suggestions below +

+ } + else + { +

+ Search results @(!string.IsNullOrEmpty(Model.SearchString) ? "for " + Model.SearchString : string.Empty) +

}
@@ -28,6 +31,12 @@ @if (Model.CatalogueSearchResult?.TotalHits > 0) { + @if (Model.DidYouMeanEnabled) + { +

+ Showing results for @(Model.SuggestedCatalogue) +

+ }
@await Html.PartialAsync("_CatalogueSearchResult", Model) @@ -37,6 +46,12 @@ @if (Model.ResourceSearchResult?.TotalHits > 0) { + @if (Model.DidYouMeanEnabled) + { +

+ Showing results for @(Model.SuggestedResource) +

+ } @await Html.PartialAsync("_ResourceFilter", Model)