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

            return PartialView(station);
        }
        public ActionResult Create(Station station)
        {
            if (ModelState.IsValid)
            {
                db.Stations.Add(station);
                db.SaveChanges();
                return PartialView("GridData", new Station[] { station });
            }

            return PartialView("Edit", station);
        }
 public ActionResult Create(Station station, int[] TimeSlotIDs)
 {
     if (ModelState.IsValid)
     {
         station.Event = db.Events.Find(eventID);
         station.AvailableTimeSlots = new List<TimeSlot>();
         if (TimeSlotIDs != null)
         {
             foreach (var timeSlotID in TimeSlotIDs)
             {
                 station.AvailableTimeSlots.Add(db.TimeSlots.Find(timeSlotID));
             }
         }
         db.Stations.Add(station);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     PrepareTimeSlotCheckBoxes();
     return View("Edit", station);
 }
 public ActionResult Edit(Station station, int[] TimeSlotIDs)
 {
     if (ModelState.IsValid)
     {
         var availableTimeSlots = new List<TimeSlot>();
         if (TimeSlotIDs != null)
         {
             foreach (var timeSlotID in TimeSlotIDs)
             {
                 availableTimeSlots.Add(db.TimeSlots.Find(timeSlotID));
             }
         }
         db.Stations.Attach(station);
         db.Entry(station).Collection(s => s.AvailableTimeSlots).Load();
         station.AvailableTimeSlots = availableTimeSlots;
         db.Entry(station).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     PrepareTimeSlotCheckBoxes();
     return View(station);
 }