Add index and create
This commit is contained in:
@@ -1,13 +1,71 @@
|
||||
using System.Web.Mvc;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using MileageTraker.Web.Models;
|
||||
using MileageTraker.Web.Utility;
|
||||
|
||||
namespace MileageTraker.Web.Controllers
|
||||
{
|
||||
public class CityController : ControllerBase
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
public class CityController : ControllerBase
|
||||
{
|
||||
[Authorize(Roles = "Administrator, Developer, Driver")]
|
||||
public JsonResult Autocomplete(string term)
|
||||
{
|
||||
var cities = DataService.GetCitiesAutocomplete(term);
|
||||
return Json(cities, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
var cities = DataService.GetCities().ToList();
|
||||
var t = cities.Select(c => Tuple.Create(c.County, c.Name));
|
||||
var groupTuple = CustomExtensions.GroupTuple(t);
|
||||
return View(groupTuple);
|
||||
}
|
||||
|
||||
public ActionResult Create(string county)
|
||||
{
|
||||
var city = new City { County = county };
|
||||
return View(city);
|
||||
}
|
||||
|
||||
//[HttpPost]
|
||||
//public ActionResult Create([Bind(Exclude = "CityId")]City city)
|
||||
//{
|
||||
// if (ModelState.IsValid)
|
||||
// {
|
||||
// DataService.AddCity(city);
|
||||
|
||||
// TempData["StatusMessage"] = "City " + city.Name + " created";
|
||||
// return RedirectToAction("Index");
|
||||
// }
|
||||
|
||||
// return View(city);
|
||||
//}
|
||||
|
||||
//public ActionResult Edit(int id = 0)
|
||||
//{
|
||||
// var city = DataService.FindCity(id);
|
||||
// if (city == null)
|
||||
// {
|
||||
// TempData["StatusMessage"] = "Purpose " + id + " not found";
|
||||
// return RedirectToAction("Index");
|
||||
// }
|
||||
// return View(city);
|
||||
//}
|
||||
|
||||
//[HttpPost]
|
||||
//public ActionResult Edit(City city)
|
||||
//{
|
||||
// if (ModelState.IsValid)
|
||||
// {
|
||||
// DataService.UpdateCity(city);
|
||||
|
||||
// TempData["StatusMessage"] = "Changes to Purpose " + city.Purpose + " saved";
|
||||
// return RedirectToAction("Index");
|
||||
// }
|
||||
// return View(city);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user