コード例 #1
0
        public ActionResult Create(City city)
        {
            if (ModelState.IsValid)
            {
                db.Cities.Add(city);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.CountryID = new SelectList(db.Provinces, "CountryID", "ProvinceName", city.CountryID);
            return View(city);
        }
コード例 #2
0
 public ActionResult Edit(City city)
 {
     if (ModelState.IsValid)
     {
         db.Entry(city).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.CountryID = new SelectList(db.Provinces, "CountryID", "ProvinceName", city.CountryID);
     return View(city);
 }