public async Task <IActionResult> Edit(int id, [Bind("TheLoaiXeId,TenTheLoaiXe,LoaiXeId")] TheLoaiXe theLoaiXe) { if (id != theLoaiXe.TheLoaiXeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(theLoaiXe); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TheLoaiXeExists(theLoaiXe.TheLoaiXeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["LoaiXeId"] = new SelectList(_context.LoaiXes, "LoaiXeId", "LoaiXeId", theLoaiXe.LoaiXeId); return(View(theLoaiXe)); }
public async Task <IActionResult> Create([Bind("TheLoaiXeId,TenTheLoaiXe,LoaiXeId")] TheLoaiXe theLoaiXe) { if (ModelState.IsValid) { _context.Add(theLoaiXe); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["LoaiXeId"] = new SelectList(_context.LoaiXes, "LoaiXeId", "LoaiXeId", theLoaiXe.LoaiXeId); return(View(theLoaiXe)); }