Exemple #1
0
        //GET
        public ActionResult AddEventToGroup(int?groupId)
        {
            AddEventToGroupViewModel addEventToGroupModel = new AddEventToGroupViewModel();

            addEventToGroupModel.Events = new SelectList(db.Events, "Id", "Name");
            addEventToGroupModel.Group  = db.Groups.Find(groupId);
            return(View(addEventToGroupModel));
        }
Exemple #2
0
 public ActionResult AddEventToGroup(AddEventToGroupViewModel model)
 {
     if (ModelState.IsValid)
     {
         GroupToEvents groupToEventToAdd = new GroupToEvents {
             GroupId = model.Group.Id, EventId = model.Event.Id
         };
         db.GroupToEvents.Add(groupToEventToAdd);
         db.SaveChanges();
     }
     return(RedirectToAction("Details", new { id = model.Group.Id }));
 }