public async Task <IActionResult> Edit(int id, [Bind("Id,StudentId,CourseId,Grade,Attendances")] CourseAttendant courseAttendant) { if (id != courseAttendant.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(courseAttendant); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseAttendantExists(courseAttendant.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CourseId"] = new SelectList(_context.CourseModel, "Id", "Name", courseAttendant.CourseId); ViewData["StudentId"] = new SelectList(_context.StudentViewModel, "id", "FullName", courseAttendant.StudentId); return(View(courseAttendant)); }
public async Task <IActionResult> Create([Bind("Id,StudentId,CourseId,Grade,Attendances")] CourseAttendant courseAttendant) { if (ModelState.IsValid) { _context.Add(courseAttendant); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CourseId"] = new SelectList(_context.CourseModel, "Id", "Name", courseAttendant.CourseId); ViewData["StudentId"] = new SelectList(_context.StudentViewModel, "id", "FullName", courseAttendant.StudentId); return(View(courseAttendant)); }