public ActionResult Create(Place place) { string userId = User.Identity.GetUserId(); place.OwnerId = userId; if (ModelState.IsValid) { db.Places.Add(place); db.SaveChanges(); return RedirectToAction("Index"); } //ViewBag.OwnerId = new SelectList(db.Users, "Id", "UserName", place.OwnerId); return View(place); }
public ActionResult Edit(Place placeviewmodel) { if (ModelState.IsValid) { db.Entry(placeviewmodel).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(placeviewmodel); }
public ActionResult Edit(Place place) { string userId = User.Identity.GetUserId(); place.OwnerId = userId; if (ModelState.IsValid) { db.Entry(place).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.OwnerId = new SelectList(db.Users, "Id", "UserName", place.OwnerId); return View(place); }