This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@{ | |
var pageInfo = string.Empty; | |
if (Model.AirportSearchResults.Count > 0) | |
{ | |
var first = @Model.Skip + 1; | |
var last = @Model.Skip + pageSize; | |
pageInfo = first + " - " + last + " of " + @Model.Count; | |
} | |
int prevSkip = @Model.Skip - pageSize; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using AFDSearch.Models | |
@model AirportSearch | |
@{ | |
ViewBag.Title = "Airport Search"; | |
} | |
@{ | |
const int pageSize = 10; | |
int currentPage = 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@foreach (FacetInfo facetInfo in Model.FacetResults) | |
{ | |
<p>@facetInfo.FacetName</p> | |
<ul> | |
@foreach (var facet in facetInfo.Facets) | |
{ | |
var facetText = @facet.Key + "(" + facet.Value + ")"; | |
var filter = string.IsNullOrEmpty(@Model.Filter) ? string.Empty : @Model.Filter + " and "; | |
<p style="margin: 0">@Html.ActionLink(facetText, "Search", new AirportSearch() {Top = pageSize, Skip = currentPage * pageSize, Filter = filter + @facetInfo.FacetName + " eq '" + @facet.Key + "'"})</p> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long count = 0; | |
var result = await azureSearchEngine.SearchDocumentsAsync<Airport>(indexName, searchText, facetfields, true, top, model.Skip, | |
model.Filter, | |
airport => new Airport() {Id = airport.Id, Identifier = airport.Identifier, Name = airport.Name, City = airport.City, State = airport.State, Chart = airport.Chart, Region = airport.Region, AfdLink = airport.AfdLink}, | |
(facetName, facets) => | |
{ | |
facetResults.Add(new FacetInfo() {FacetName = facetName, Facets = facets}); | |
}, | |
documentCount => { if (null != documentCount) count = documentCount.Value; }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
namespace AFDSearch.Models | |
{ | |
public class AirportSearch | |
{ | |
public AirportSearch() | |
{ | |
AirportSearchResults = new List<Airport>(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using AFDSearch.Models | |
@model AirportSearch | |
@{ | |
ViewBag.Title = "Airport Search"; | |
} | |
<style> | |
p { | |
font-size: 12px; | |
} | |
ul, li{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Configuration; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using System.Web.Mvc; | |
using AFDSearch.Models; | |
using BlackBarLabs.Search.Azure; | |
namespace AFDSearch.Controllers | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var resultsModel = new AirportSearch(); | |
resultsModel.SearchText = model.SearchText; | |
resultsModel.AirportSearchResults = result.ToList(); | |
resultsModel.FacetResults = facetResults; | |
resultsModel.Filter = model.Filter; | |
return View(resultsModel); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = await azureSearchEngine.SearchDocumentsAsync<Airport>(indexName, searchText, facetfields, true, top, null, | |
model.Filter, | |
airport => new Airport() {Id = airport.Id, Identifier = airport.Identifier, Name = airport.Name, City = airport.City, State = airport.State, Chart = airport.Chart, Region = airport.Region, AfdLink = airport.AfdLink}, | |
(facetName, facets) => | |
{ | |
facetResults.Add(new FacetInfo() {FacetName = facetName, Facets = facets}); | |
}, | |
count => { }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// By default, we want to get back no results, but we want to get facet and count information for the entire result set | |
int? top = DefaultTopCount; | |
var searchText = model.SearchText; | |
if (string.IsNullOrEmpty(searchText) && string.IsNullOrEmpty(model.Filter)) | |
{ | |
searchText = "*"; | |
top = 0; | |
} |
NewerOlder