public ActionResult Edit(Group group)
        {
            if (ModelState.IsValid)
            {
                db.Entry(group).State = EntityState.Modified;
                db.SaveChanges();
                return PartialView("GridData", new Group[] { group });
            }

            return PartialView(group);
        }
        public ActionResult Create(Group group)
        {
            if (ModelState.IsValid)
            {
                db.Groups.Add(group);
                db.SaveChanges();
                return PartialView("GridData", new Group[] { group });
            }

            return PartialView("Edit", group);
        }
 public ActionResult Create(Group group)
 {
     if (ModelState.IsValid)
     {
         group.Event = db.Events.Find(eventID);
         group.Type = db.GroupTypes.Find(group.TypeID);
         group.Preference1 = db.Stations.Find(group.Preference1.ID);
         group.Preference2 = db.Stations.Find(group.Preference2.ID);
         group.Preference3 = db.Stations.Find(group.Preference3.ID);
         group.Preference4 = db.Stations.Find(group.Preference4.ID);
         group.Preference5 = db.Stations.Find(group.Preference5.ID);
         db.Groups.Add(group);
         db.SaveChanges();
         return PartialView("GridData", new Group[] { group });
     }
     return PartialEditView(group);
 }
 public ActionResult Edit(Group group)
 {
     if (ModelState.IsValid)
     {
         Group origGroup = db.Groups
                             .Include(g => g.Preference1)
                             .Include(g => g.Preference2)
                             .Include(g => g.Preference3)
                             .Include(g => g.Preference4)
                             .Include(g => g.Preference5)
                             .Single(g => g.ID == group.ID);
         db.Entry(origGroup).CurrentValues.SetValues(group);
         origGroup.Preference1 = db.Stations.Find(group.Preference1.ID);
         origGroup.Preference2 = db.Stations.Find(group.Preference2.ID);
         origGroup.Preference3 = db.Stations.Find(group.Preference3.ID);
         origGroup.Preference4 = db.Stations.Find(group.Preference4.ID);
         origGroup.Preference5 = db.Stations.Find(group.Preference5.ID);
         db.SaveChanges();
         return PartialView("GridData", new Group[] { origGroup });
     }
     return PartialEditView(group);
 }
 protected PartialViewResult PartialEditView(Group group = null)
 {
     ViewBag.GroupTypes = db.GroupTypes.ToList();
     ViewBag.Stations = db.Stations.Where(s => s.Event.ID == eventID).ToList();
     ViewBag.Stations.Insert(0, new Station { ID = -1 }); // Allow null preferences
     return PartialView("Edit", group);
 }