protected void SearchButton_Click(object sender, EventArgs e) { if (SearchBand.Text == "") { bandJson = JSONGenerator.generateBandJSON(); } else { bandJson = SearchUtility.SearchBands(SearchBand.Text); } }
protected void Page_Load(object sender, EventArgs e) { bandJson = JSONGenerator.generateBandJSON(); bandNames = JSONGenerator.generateBandNames(); }
public static string SearchBands(string searchString) { BandsCollection bands = JsonConvert.DeserializeObject <BandsCollection>(JSONGenerator.generateBandJSON()); List <BandJSON> searchResults = new List <BandJSON>(); foreach (BandJSON band in bands.band) { if (band.BandName.IndexOf(searchString, StringComparison.CurrentCultureIgnoreCase) != -1) { searchResults.Add(band); } } BandsCollection result = new BandsCollection(); result.band = searchResults; return(JsonConvert.SerializeObject(result)); }