예제 #1
0
        public ActionResult ProvinceEdit(Province model)
        {
            var province = db.Provinces.Find(model.ID);

            if (ModelState.IsValid)
            {
                province.ProvinceName = model.ProvinceName;
                db.SaveChanges();
                return Redirect("/Admin/Foundation/Province");
            }
            else
            {
                ModelState.AddModelError("", "省份信息填写失败!");
            }
            return View(province);
        }
예제 #2
0
 public ActionResult ProvinceDelete(int id)
 {
     try
     {
         var province = new Province();
         province = db.Provinces.Find(id);
         db.Provinces.Remove(province);
         db.SaveChanges();
         return Content("ok");
     }
     catch
     {
         return Content("err");
     }
 }
예제 #3
0
 public ActionResult ProvinceEdit(int id)
 {
     var province = new Province();
     province = db.Provinces.Find(id);
     return View(province);
 }
예제 #4
0
 public ActionResult AddProvince(Province model)
 {
     if (ModelState.IsValid)
     {
         var province = new Province();
         province.ProvinceName = model.ProvinceName;
         db.Provinces.Add(province);
         db.SaveChanges();
         return Redirect("/Admin/Foundation/Province");
     }
     else
     {
         ModelState.AddModelError("", "省份信息填写失败!");
     }
     return View();
 }