public string SummariseRequestedSearch(List <SearchTerm> searchTerms) { StringBuilder oStringBuilder = new StringBuilder(); oStringBuilder.AppendLine("<p><strong>You searched for:</strong><br/>"); foreach (SearchTerm searchTerm in searchTerms) { switch (searchTerm.SearchType) { case SearchTermSelection.ImageCaption: oStringBuilder.AppendLine( "Image caption contains " + SearchTermGenerator.ReturnSearchTermSummary(searchTerm.StringVals, "AND") + "<br/>"); break; case SearchTermSelection.ImageName: oStringBuilder.AppendLine( "Image name contains " + SearchTermGenerator.ReturnSearchTermSummary(searchTerm.StringVals, "AND") + "<br/>"); break; case SearchTermSelection.MarkerName: oStringBuilder.AppendLine( "Image name contains " + SearchTermGenerator.ReturnSearchTermSummary(searchTerm.StringVals, "AND") + "<br/>"); break; } } return(oStringBuilder.ToString()); }
public List <SearchTerm> ParseSearchForm(NameValueCollection formCollection) { var searchTerms = new List <SearchTerm>(); if (!string.IsNullOrEmpty(formCollection["SearchImageCaption"])) { string[] searchWords = SearchTermGenerator.ReturnSearchTerms(formCollection["SearchImageCaption"]); searchTerms.Add(new SearchTerm(searchWords, SearchTermSelection.ImageCaption)); } if (!string.IsNullOrEmpty(formCollection["SearchImageName"])) { string[] searchWords = SearchTermGenerator.ReturnSearchTerms(formCollection["SearchImageName"]); searchTerms.Add(new SearchTerm(searchWords, SearchTermSelection.ImageName)); } if (!string.IsNullOrEmpty(formCollection["SearchMarkerName"])) { string[] searchWords = SearchTermGenerator.ReturnSearchTerms(formCollection["SearchMarkerName"]); searchTerms.Add(new SearchTerm(searchWords, SearchTermSelection.MarkerName)); } return(searchTerms); }
public List <SearchTerm> ParseSearchForm(NameValueCollection formCollection) { var searchTerms = new List <SearchTerm>(); if (!string.IsNullOrEmpty(formCollection["SearchTitle"])) { string[] searchWords = SearchTermGenerator.ReturnSearchTerms(formCollection["SearchTitle"]); searchTerms.Add(new SearchTerm(searchWords, SearchTermSelection.Title)); } if (!string.IsNullOrEmpty(formCollection["SearchWalkDescription"])) { string[] searchWords = SearchTermGenerator.ReturnSearchTerms(formCollection["SearchWalkDescription"]); searchTerms.Add(new SearchTerm(searchWords, SearchTermSelection.Description)); } if (!string.IsNullOrEmpty(formCollection["SearchImageCaptions"])) { string[] searchWords = SearchTermGenerator.ReturnSearchTerms(formCollection["SearchImageCaptions"]); searchTerms.Add(new SearchTerm(searchWords, SearchTermSelection.ImageCaption)); } if (!string.IsNullOrEmpty(formCollection["SearchHillAscended"])) { string[] searchWords = SearchTermGenerator.ReturnSearchTerms(formCollection["SearchHillAscended"]); searchTerms.Add(new SearchTerm(searchWords, SearchTermSelection.HillAscended)); } if (!string.IsNullOrEmpty(formCollection["SearchLength"])) { double lengthVal = double.Parse(formCollection["SearchLength"]); SearchOperator searchOperator; if (formCollection["LengthGtLt"].Equals(">")) { searchOperator = SearchOperator.GreaterThan; } else { searchOperator = SearchOperator.LessThan; } searchTerms.Add(new SearchTerm(lengthVal, SearchTermSelection.WalkLength, searchOperator)); } if (!string.IsNullOrEmpty(formCollection["SearchAscent"])) { int ascentVal = Int32.Parse(formCollection["SearchAscent"]); SearchOperator searchOperator; if (formCollection["AscentGtLt"].Equals(">")) { searchOperator = SearchOperator.GreaterThan; } else { searchOperator = SearchOperator.LessThan; } searchTerms.Add(new SearchTerm(ascentVal, SearchTermSelection.MetresAscent, searchOperator)); } if (!string.IsNullOrEmpty(formCollection["SearchOverallSpeed"])) { double speedVal = double.Parse(formCollection["SearchOverallSpeed"]); SearchOperator searchOperator; if (formCollection["OverallSpeedGtLt"].Equals(">")) { searchOperator = SearchOperator.GreaterThan; } else { searchOperator = SearchOperator.LessThan; } searchTerms.Add(new SearchTerm(speedVal, SearchTermSelection.OverallSpeed, searchOperator)); } if (!string.IsNullOrEmpty(formCollection["DateFromDay"]) && !string.IsNullOrEmpty(formCollection["DateFromYear"])) { string stringDate = formCollection["DateFromDay"] + " " + formCollection["DateFromMonth"] + " " + formCollection["DateFromYear"]; DateTime fromDate = DateTime.Parse(stringDate); SearchOperator searchOperator = SearchOperator.GreaterThan; searchTerms.Add(new SearchTerm(fromDate, SearchTermSelection.WalkDateFrom, searchOperator)); } if (!string.IsNullOrEmpty(formCollection["DateToDay"]) && !string.IsNullOrEmpty(formCollection["DateToYear"])) { string stringDate = formCollection["DateToDay"] + " " + formCollection["DateToMonth"] + " " + formCollection["DateToYear"]; DateTime toDate = DateTime.Parse(stringDate); SearchOperator searchOperator = SearchOperator.LessThan; searchTerms.Add(new SearchTerm(toDate, SearchTermSelection.WalkDateTo, searchOperator)); } if (!string.IsNullOrEmpty(formCollection["SearchDurationHours"]) && !string.IsNullOrEmpty(formCollection["SearchDurationMins"])) { int durationHour = Int32.Parse(formCollection["SearchDurationHours"]); int durationMins = Int32.Parse(formCollection["SearchDurationMins"]); DateTime walkDuration = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, durationHour, durationMins, 0); SearchOperator searchOperator; if (formCollection["DurationGtLt"].Equals(">")) { searchOperator = SearchOperator.GreaterThan; } else { searchOperator = SearchOperator.LessThan; } searchTerms.Add(new SearchTerm(walkDuration, SearchTermSelection.WalkDuration, searchOperator)); } return(searchTerms); }
public string SummariseRequestedSearch(List <SearchTerm> searchTerms) { StringBuilder oStringBuilder = new StringBuilder(); oStringBuilder.AppendLine("<p><strong>You searched for:</strong><br/>"); foreach (SearchTerm searchTerm in searchTerms) { switch (searchTerm.SearchType) { case SearchTermSelection.HillAscended: oStringBuilder.AppendLine("Hill ascended contains " + SearchTermGenerator.ReturnSearchTermSummary(searchTerm.StringVals, "AND") + "<br/>"); break; case SearchTermSelection.Description: oStringBuilder.AppendLine("walk description contains " + SearchTermGenerator.ReturnSearchTermSummary(searchTerm.StringVals, "AND") + "<br/>"); break; case SearchTermSelection.ImageCaption: oStringBuilder.AppendLine("Walk has image caption which contains " + SearchTermGenerator.ReturnSearchTermSummary(searchTerm.StringVals, "AND") + "<br/>"); break; case SearchTermSelection.MetresAscent: if (searchTerm.SearchOperator == SearchOperator.GreaterThan) { oStringBuilder.AppendLine("Ascent at least <em>" + searchTerm.IntVal.ToString() + "</em> metres<br/>"); } else { oStringBuilder.AppendLine("Ascent less than <em>" + searchTerm.IntVal.ToString() + "</em> metres<br/>"); } break; case SearchTermSelection.OverallSpeed: if (searchTerm.SearchOperator == SearchOperator.GreaterThan) { oStringBuilder.AppendLine("Overall speed at least <em>" + searchTerm.DoubleVal.ToString() + "</em> km/h<br/>"); } else { oStringBuilder.AppendLine("Overall speed than <em>" + searchTerm.DoubleVal.ToString() + "</em> km/h<br/>"); } break; case SearchTermSelection.Title: oStringBuilder.AppendLine("Walk title contains " + SearchTermGenerator.ReturnSearchTermSummary(searchTerm.StringVals, "AND") + "<br/>"); break; case SearchTermSelection.WalkDateFrom: oStringBuilder.AppendLine("Walk date after <em>" + searchTerm.DateTimeVal.ToString("dd MMMM yyyy") + "</em><br/>"); break; case SearchTermSelection.WalkDateTo: oStringBuilder.AppendLine("Walk date before <em>" + searchTerm.DateTimeVal.ToString("dd MMMM yyyy") + "</em><br/>"); break; case SearchTermSelection.WalkDuration: if (searchTerm.SearchOperator == SearchOperator.GreaterThan) { oStringBuilder.AppendLine("Duration at least <em>" + searchTerm.DateTimeVal.Hour.ToString() + " hr " + searchTerm.DateTimeVal.Minute.ToString() + " min</em><br/>"); } else { oStringBuilder.AppendLine("Duration less than <em>" + searchTerm.DateTimeVal.Hour.ToString() + " hr " + searchTerm.DateTimeVal.Minute.ToString() + " min</em><br/>"); } break; case SearchTermSelection.WalkLength: if (searchTerm.SearchOperator == SearchOperator.GreaterThan) { oStringBuilder.AppendLine("Length at least <em>" + searchTerm.DoubleVal.ToString() + "</em> km<br/>"); } else { oStringBuilder.AppendLine("Length less than <em>" + searchTerm.DoubleVal.ToString() + "</em> km<br/>"); } break; } } return(oStringBuilder.ToString()); }