示例#1
0
 public ActionResult Edit([Bind(Include = "ScheduleID,Active,Title,Date,GroupSize,MaxParticipants,Program")] Schedule schedule)
 {
     if (ModelState.IsValid)
     {
         db.Entry(schedule).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(schedule));
 }
示例#2
0
 public ActionResult Edit([Bind(Include = "Participant")] ParticipantViewModel participantVM)
 {
     ModelState.Remove("Participant.Schedules");
     if (ModelState.IsValid)
     {
         var oldParticipant = db.Participants.FirstOrDefault(p => p.ParticipantID == participantVM.Participant.ParticipantID);
         var scheduleIds    = Request.Form.Get("Participant.Schedules");
         oldParticipant.Schedules.Clear();
         foreach (var id in scheduleIds.Split(','))
         {
             int i = int.Parse(id);
             oldParticipant.Schedules.Add(
                 db.Schedules.FirstOrDefault(s => s.ScheduleID == i));
         }
         //foreach(int id in )
         db.Entry(oldParticipant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(participantVM));
 }