Autocomplete service center name

This commit is contained in:
2015-10-12 22:45:36 -04:00
parent d87f654a20
commit 49c55ffba6
6 changed files with 39 additions and 1 deletions
@@ -105,5 +105,11 @@ namespace MileageTraker.Web.Controllers
}
return View(viewModel);
}
public JsonResult ServiceCenterNameAutocomplete(string term)
{
var names = DataService.GetServiceCenterNamesAutocomplete(term);
return Json(names, JsonRequestBehavior.AllowGet);
}
}
}
+17
View File
@@ -858,6 +858,23 @@ namespace MileageTraker.Web.DAL
return vehicleServices;
}
public IQueryable<string> GetServiceCenterNames()
{
return
from l in GetVehicleServices()
group l by new {l.ServiceCenterName}
into g
select g.Key.ServiceCenterName;
}
public IEnumerable<string> GetServiceCenterNamesAutocomplete(string term)
{
return
from name in GetServiceCenterNames()
where name.StartsWith(term)
select name;
}
#endregion
}
+5
View File
@@ -12,6 +12,11 @@ $(function () {
source: "/User/Autocomplete",
minLength: 2
});
$("input#ServiceCenterName").autocomplete({
source: "/VehicleService/ServiceCenterNameAutocomplete",
minLength: 2
});
$("form select#Year").change(function () {
var year = $(this).val();
+1 -1
View File
@@ -2,7 +2,7 @@
ViewBag.Title = "No Fuel Logs";
}
<h2 class="center-content">@ViewBag.Title</h2>
<h2 class="center-content"><i class="fa fa-tachometer"></i> @ViewBag.Title</h2>
<div class="center-content well">
No Fuel logs have been added yet. @Html.ActionLink("Import", "ImportUpload", null, new { @class = "btn" })
+9
View File
@@ -0,0 +1,9 @@
@{
ViewBag.Title = "No Vehicle Service";
}
<h2 class="center-content"><i class="fa fa-wrench"></i> @ViewBag.Title</h2>
<div class="center-content well">
No Vehicle Services have been added yet. @Html.ActionLink("Add Service", "Create", null, new { @class = "btn" })
</div>
+1
View File
@@ -335,6 +335,7 @@
<Content Include="Views\VehicleService\Edit.cshtml" />
<Content Include="Views\VehicleService\Details.cshtml" />
<Content Include="Views\Shared\EditorTemplates\VehicleServiceResultsViewModel.cshtml" />
<Content Include="Views\VehicleService\Empty.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Content\Account.Login.css" />