public async Task <IActionResult> Edit(string id, [Bind("MaHp,MaMh,Hocky,Nam,Giangvien")] Hocphan hocphan) { if (id != hocphan.MaHp) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(hocphan); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HocphanExists(hocphan.MaHp)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MaMh"] = new SelectList(_context.Monhoc, "MaMh", "MaMh", hocphan.MaMh); return(View(hocphan)); }
public async Task <IActionResult> Create([Bind("MaHp,MaMh,Hocky,Nam,Giangvien")] Hocphan hocphan) { if (ModelState.IsValid) { _context.Add(hocphan); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MaMh"] = new SelectList(_context.Monhoc, "MaMh", "MaMh", hocphan.MaMh); return(View(hocphan)); }