public ActionResult Edit(Place place, int? page = 1, int? count = __default_count) { ViewBag.Page = page = page.HasValue && page > 1 ? page : 1; ViewBag.Count = count = count.HasValue && count > __default_count ? count : __default_count; if (ModelState.IsValid) { DB.Entry(place).State = EntityState.Modified; DB.SaveChanges(); return RedirectToAction("Index"); } //ViewBag.RegionId = new SelectList(db.Regions, "RegionId", "Name", place.RegionId); ViewBag.Regions = DB.Regions.ToList(); return View(place); }
public ActionResult Create(Place place, int? page = 1, int? count = __default_count) { ViewBag.Page = page = page.HasValue && page > 1 ? page : 1; ViewBag.Count = count = count.HasValue && count > __default_count ? count : __default_count; if (ModelState.IsValid) { //place.Region = db.Regions.Find(place.RegionId); DB.Places.Add(place); DB.SaveChanges(); return RedirectToAction("Index", new { count = count, page = page }); } //ViewBag.RegionId = new SelectList(db.Regions, "RegionId", "Name", place.RegionId); ViewBag.Regions = DB.Regions.ToList(); return View(place); }