public async Task <IActionResult> Edit(string id, [Bind("XpMa,XpTen")] Xaphuong xaphuong) { if (id != xaphuong.XpMa) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(xaphuong); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!XaphuongExists(xaphuong.XpMa)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(xaphuong)); }
public async Task <IActionResult> Create([Bind("XpMa,XpTen")] Xaphuong xaphuong) { if (ModelState.IsValid) { _context.Add(xaphuong); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(xaphuong)); }