Begin adding fluxnet site autocomplete
This commit is contained in:
+11
-1
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.Entity;
|
using System.Data.Entity;
|
||||||
|
using System.Linq;
|
||||||
using LeafWeb.Core.Models;
|
using LeafWeb.Core.Models;
|
||||||
|
|
||||||
namespace LeafWeb.Core.DAL
|
namespace LeafWeb.Core.DAL
|
||||||
@@ -22,10 +23,19 @@ namespace LeafWeb.Core.DAL
|
|||||||
|
|
||||||
#region Fluxnet Sites
|
#region Fluxnet Sites
|
||||||
|
|
||||||
public IEnumerable<FluxnetSite> GetFluxnetSites()
|
public IQueryable<FluxnetSite> GetFluxnetSites()
|
||||||
{
|
{
|
||||||
return _db.FluxnetSites;
|
return _db.FluxnetSites;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IQueryable<FluxnetSite> GetFluxnetSitesAutocomplete(string term)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
from fs in GetFluxnetSites()
|
||||||
|
where fs.FluxnetId.StartsWith(term)
|
||||||
|
|| fs.SiteName.Contains(term)
|
||||||
|
select fs;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using LeafWeb.Core.DAL;
|
||||||
|
|
||||||
|
namespace LeafWeb.Web.Controllers
|
||||||
|
{
|
||||||
|
//[UserActivity]
|
||||||
|
public class ControllerBase : Controller
|
||||||
|
{
|
||||||
|
protected readonly DataService DataService = new DataService();
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
DataService.Dispose();
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System.Web.Mvc;
|
||||||
|
using LeafWeb.Core.DAL;
|
||||||
|
|
||||||
|
namespace LeafWeb.Web.Controllers
|
||||||
|
{
|
||||||
|
public class FluxnetSiteController : ControllerBase
|
||||||
|
{
|
||||||
|
public JsonResult Autocomplete(string term)
|
||||||
|
{
|
||||||
|
var cities = DataService.GetFluxnetSitesAutocomplete(term);
|
||||||
|
return Json(cities, JsonRequestBehavior.AllowGet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,10 +10,6 @@ namespace LeafWeb.Web.Controllers
|
|||||||
{
|
{
|
||||||
public ActionResult Index()
|
public ActionResult Index()
|
||||||
{
|
{
|
||||||
var dataService = new DataService();
|
|
||||||
var fluxnetSites = dataService.GetFluxnetSites().ToList();
|
|
||||||
|
|
||||||
|
|
||||||
// initialize the session storage to retain SessionID between requests
|
// initialize the session storage to retain SessionID between requests
|
||||||
Session["placeholder"] = 0;
|
Session["placeholder"] = 0;
|
||||||
return View();
|
return View();
|
||||||
|
|||||||
Reference in New Issue
Block a user