示例#1
0
 public ActionResult AddCity(City model)
 {
     var provinces = db.Provinces.ToList();
     ViewBag.Provinces = provinces;
     if (ModelState.IsValid)
     {
         var city = new City();
         city.CityName = model.CityName;
         city.ProvinceID = model.ProvinceID;
         db.Cities.Add(city);
         db.SaveChanges();
         return Redirect("/Admin/Foundation/City");
     }
     else
     {
         ModelState.AddModelError("", "城市信息填写失败!");
     }
     return View();
 }
示例#2
0
 public ActionResult CityEdit(City model)
 {
     var city = db.Cities.Find(model.ID);
     ViewBag.City = city;
     if (ModelState.IsValid)
     {
         city.CityName = model.CityName;
         city.ProvinceID = model.ProvinceID;
         db.SaveChanges();
         return Redirect("/Admin/Foundation/City");
     }
     else
     {
         ModelState.AddModelError("", "城市信息填写失败!");
     }
     return View();
 }
示例#3
0
 public ActionResult CityEdit(int id)
 {
     var city = new City();
     city = db.Cities.Find(id);
     ViewBag.City = city;
     var provinces = db.Provinces.ToList();
     ViewBag.Provinces = provinces;
     return View();
 }
示例#4
0
 public ActionResult CityDelete(int id)
 {
     var city = new City();
     city = db.Cities.Find(id);
     db.Cities.Remove(city);
     db.SaveChanges();
     return Content("ok");
 }