public ActionResult Delete(Guest g, int id) { try { Guest Guest2Remove = Db.Guests.FirstOrDefault(x => x.GuestId == id); Db.Guests.Remove(Guest2Remove); Db.SaveChanges(); return RedirectToAction("Index", "Events"); } catch { return View(); } }
public ActionResult Create(Guest g, int id) { if (g.Email == null) { return RedirectToAction("Create"); } try { Guest newGuest = new Guest { FirstName = g.FirstName, LastName=g.LastName, Email=g.Email}; Event eve = Db.Events.FirstOrDefault(x => x.EventId == id); eve.GuestsList.Add(newGuest); Db.SaveChanges(); return RedirectToAction("Details", "Events", new { id = id }); } catch { return View(); } }