public async Task <IActionResult> Edit(int id, [Bind("TeacherId,TeacherName,TeacherDept")] TeacherDb teacherDb) { if (id != teacherDb.TeacherId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(teacherDb); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TeacherDbExists(teacherDb.TeacherId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(teacherDb)); }
public async Task <IActionResult> Create([Bind("TeacherId,TeacherName,TeacherDept")] TeacherDb teacherDb) { if (ModelState.IsValid) { _context.Add(teacherDb); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(teacherDb)); }