public async Task <IActionResult> Edit([Bind("EnrollmentId,MusicClassId,Date")] EnrollmentMusicClass enrollmentMusicClass) { System.Diagnostics.Debug.WriteLine(enrollmentMusicClass.EnrollmentId); if (ModelState.IsValid) { try { _context.Update(enrollmentMusicClass); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnrollmentMusicClassExists(enrollmentMusicClass.EnrollmentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EnrollmentId"] = new SelectList(_context.Enrollment, "EnrollmentId", "EnrollmentId", enrollmentMusicClass.EnrollmentId); ViewData["MusicClassId"] = new SelectList(_context.MusicClass, "MusicClassId", "MusicClassId", enrollmentMusicClass.MusicClassId); return(View(enrollmentMusicClass)); }
public async Task <IActionResult> Create([Bind("EnrollmentId,MusicClassId,Date")] EnrollmentMusicClass enrollmentMusicClass) { if (ModelState.IsValid) { _context.Add(enrollmentMusicClass); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EnrollmentId"] = new SelectList(_context.Enrollment, "EnrollmentId", "EnrollmentId", enrollmentMusicClass.EnrollmentId); ViewData["MusicClassId"] = new SelectList(_context.MusicClass, "MusicClassId", "MusicClassId", enrollmentMusicClass.MusicClassId); return(View(enrollmentMusicClass)); }
public async Task <IActionResult> AddStudent(EnrollmentMusicClass enrollmentMusicClass) { enrollmentMusicClass.Date = DateTime.Now; if (ModelState.IsValid) { _context.Add(enrollmentMusicClass); await _context.SaveChangesAsync(); return(RedirectToAction("Edit", "MusicClasses", new { id = enrollmentMusicClass.MusicClassId })); } ViewData["EnrollmentId"] = new SelectList(_context.Enrollment, "EnrollmentId", "EnrollmentId", enrollmentMusicClass.EnrollmentId); ViewData["MusicClassId"] = new SelectList(_context.MusicClass, "MusicClassId", "MusicClassId", enrollmentMusicClass.MusicClassId); return(View(enrollmentMusicClass)); }