Ejemplo n.º 1
0
        public JsonResult HillSuggestions(string term, string areaid = "")
        {
            var hillsuggestions = new List <AutocompleteSuggestionOption>();

            IQueryable <Hill> IQHillsAboveHeight;

            if (areaid.Equals("") && areaid.Length < 2)
            {
                IQHillsAboveHeight = this.repository.FindHillsByNameLike(term);
            }
            else
            {
                IQHillsAboveHeight = this.repository.FindHillsInAreaByNameLike(term, areaid);
            }

            foreach (Hill item in IQHillsAboveHeight)
            {
                var optionlabel = WalkingStick.FormatHillSummaryAsLine(item);
                var optionvalue = optionlabel + "|" + item.Hillnumber;

                hillsuggestions.Add(new AutocompleteSuggestionOption {
                    label = optionlabel, value = optionvalue
                });
            }

            return(Json(hillsuggestions, JsonRequestBehavior.AllowGet));
        }