public ActionResult Create(Participation participation) { if (ModelState.IsValid) { db.Participations.Add(participation); db.SaveChanges(); return RedirectToAction("Index"); } var viewModel = new ParticipationViewModel(GetActivityList(), GetStudentsList()) { Participation = participation }; return View(viewModel); }
// // GET: /Participation/Edit/5 public ActionResult Edit(int id = 0) { Participation participation = db.Participations.Find(id); if (participation == null) { return HttpNotFound(); } var viewModel = new ParticipationViewModel(GetActivityList(), GetStudentsList()) { Participation = participation }; return View(viewModel); }
// // GET: /Participation/Create public ActionResult Create() { var viewModel = new ParticipationViewModel(GetActivityList(), GetStudentsList()); return View(viewModel); }
public ActionResult Edit(Participation participation) { if (ModelState.IsValid) { participation.Activity = db.Activities.Find(participation.ActivityId); participation.Subject = db.Subjects.Find(participation.Subject.SubjectId); participation.Student = db.Students.Find(participation.StudentId); db.Entry(participation).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } var viewModel = new ParticipationViewModel(GetActivityList(), GetStudentsList()) { Participation = participation }; return View(viewModel); }