Auto complete for FluxnetSite

This commit is contained in:
2016-02-01 10:39:43 -05:00
parent c5fcb8d635
commit 8f0f0ff1b8
12 changed files with 1096 additions and 37 deletions
+15 -5
View File
@@ -1,14 +1,24 @@
using System.Web.Mvc;
using LeafWeb.Core.DAL;
using System.Linq;
using System.Web.Mvc;
namespace LeafWeb.Web.Controllers
{
public class FluxnetSiteController : ControllerBase
{
public JsonResult Autocomplete(string term)
public JsonResult Autocomplete(string query)
{
var cities = DataService.GetFluxnetSitesAutocomplete(term);
return Json(cities, JsonRequestBehavior.AllowGet);
var sites = DataService.GetFluxnetSitesAutocomplete(query).Take(50).ToList();
var data = new
{
suggestions =
from s in sites
select new
{
value = $"{s.SiteName} / {s.FluxnetId}",
data = s.FluxnetId
}
};
return Json(data, JsonRequestBehavior.AllowGet);
}
}
}