示例#1
0
        public ActionResult Create(Country country)
        {
            if (ModelState.IsValid)
            {
                db.Countries.Add(country);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(country);
        }
示例#2
0
        public PhilippinesData()
        {
            Country philippines = new Country(){Name ="Philippines",

                Provinces = new List<Province>(){

                    new Province(){Name="Zamboanga del Sur", Cities= new List<City>()
                            {new City(){Name="Zamboanga City"}, new City(){Name="Pagadian"}}},

                    new Province(){Name="Zamboanga del Norte",
                        Cities = new List<City>()
                            {new City(){Name="Dipolog"},new City(){Name="Dapitan"}}},

                    new Province(){Name="Zamboanga Sibugay",Cities = new List<City>()
                            {new City(){Name="Ipil"}}}
                }
            };

            using (FindABookContext db = new FindABookContext())
            {
                db.Countries.Add(philippines);
                db.SaveChanges();
            }
        }
示例#3
0
 public ActionResult Edit(Country country)
 {
     if (ModelState.IsValid)
     {
         db.Entry(country).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(country);
 }