public ActionResult Create(Event newEvent) { newEvent.weddingID = User.UserId; if (ModelState.IsValid) { db.Events.Add(newEvent); db.SaveChanges(); return RedirectToAction("Index"); } else return View(newEvent); // if not valid, show the form again }
public ActionResult Delete(int id, Event deletedEvent) { try { db.Entry(deletedEvent).State = EntityState.Deleted; db.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(int id, Event editedEvent) { editedEvent.weddingID = User.UserId; if (ModelState.IsValid) { db.Entry(editedEvent).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(editedEvent); }