Ejemplo n.º 1
0
 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");
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public ActionResult Edit(Event @event)
 {
     if (ModelState.IsValid)
     {
         db.Entry(@event).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(@event);
 }