public ActionResult CreateEvent(Event @event) { var subscribedUsers = GetAllSubscribedUsers(); subscribedUsers.ForEach(u => @event.EventParticipants.Add(new EventParticipant() { User = u, Event = @event, IsPaid = false, WasAnnounced = true, WasPresent = false })); dbContext.Events.Add(@event); dbContext.SaveChanges(); return RedirectToAction("index"); }
public ActionResult Create(Event @event) { if (ModelState.IsValid) { db.Users.Where(u => u.IsSubscribed).ToList().ForEach((u) => { db.EventParticipants.Add(new EventParticipant() { Event = @event, User = u, }); } ); db.Events.Add(@event); db.SaveChanges(); return RedirectToAction("Index"); } return View(@event); }
public ActionResult Edit(Event @event) { if (ModelState.IsValid) { db.Entry(@event).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(@event); }