コード例 #1
0
        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);
        }
コード例 #2
0
        public ActionResult Create(Station station)
        {
            if (ModelState.IsValid)
            {
                db.Stations.Add(station);
                db.SaveChanges();
                return PartialView("GridData", new Station[] { station });
            }

            return PartialView("Edit", station);
        }
コード例 #3
0
 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);
 }
コード例 #4
0
 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);
 }