public ActionResult Create(VenueModel model) { if (ModelState.IsValid) { // Gotta do this first to get the identity column. model.UserId = User.Identity.Name; Db.Venues.Add(model); Db.SaveChanges(); return RedirectToAction("Index"); } return View(model); }
public ActionResult Edit(VenueModel model) { if ( !User.IsInRole("Admin") && model.UserId != User.Identity.Name ) { return View("NotYourVenue"); } if (ModelState.IsValid) { Db.Entry(model).State = EntityState.Modified; Db.SaveChanges(); return RedirectToAction("Index"); } return View(model); }