public async Task <IActionResult> Edit(int id, [Bind("id,student_id,subject_id,teacher_id,grade,date")] student_subject_registration student_subject_registration) { if (id != student_subject_registration.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(student_subject_registration); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!student_subject_registrationExists(student_subject_registration.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["student_id"] = new SelectList(_context.students, "code", "code", student_subject_registration.student_id); ViewData["subject_id"] = new SelectList(_context.subject, "id", "id", student_subject_registration.subject_id); ViewData["teacher_id"] = new SelectList(_context.teachers, "id", "id", student_subject_registration.teacher_id); return(View(student_subject_registration)); }
public async Task <IActionResult> Create([Bind("id,student_id,subject_id,teacher_id,grade,date")] student_subject_registration student_subject_registration) { if (ModelState.IsValid) { _context.Add(student_subject_registration); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["student_id"] = new SelectList(_context.students, "code", "code", student_subject_registration.student_id); ViewData["subject_id"] = new SelectList(_context.subject, "id", "id", student_subject_registration.subject_id); ViewData["teacher_id"] = new SelectList(_context.teachers, "id", "id", student_subject_registration.teacher_id); return(View(student_subject_registration)); }