Auto complete for FluxnetSite
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user