Example #1
0
 public ActionResult Create(ProvinceViewModel province)
 {
     if (ModelState.IsValid)
     {
         Country country= db.Countries.Find(province.CountryId);
         Province p = new Province();
         p.Name = province.Name;
         country.Provinces.Add(p);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.CountryId = new SelectList(db.Countries.ToList(), "Id", "Name", province.Id);
     return View(province);
 }
Example #2
0
 public ActionResult Edit(Province province)
 {
     if (ModelState.IsValid)
     {
         db.Entry(province).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(province);
 }