public async Task <IActionResult> Edit(int id, [Bind("MauDongXeId,MauXeId,DongXeId")] MauDongXe mauDongXe) { if (id != mauDongXe.MauDongXeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(mauDongXe); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MauDongXeExists(mauDongXe.MauDongXeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DongXeId"] = new SelectList(_context.DongXe, "DongXeId", "TenDongXe", mauDongXe.DongXeId); ViewData["MauXeId"] = new SelectList(_context.MauXe, "MauXeId", "TenMauXe", mauDongXe.MauXeId); return(View(mauDongXe)); }
public async Task <IActionResult> Create([Bind("MauDongXeId,MauXeId,DongXeId")] MauDongXe mauDongXe) { if (ModelState.IsValid) { _context.Add(mauDongXe); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DongXeId"] = new SelectList(_context.DongXe, "DongXeId", "TenDongXe", mauDongXe.DongXeId); ViewData["MauXeId"] = new SelectList(_context.MauXe, "MauXeId", "TenMauXe", mauDongXe.MauXeId); return(View(mauDongXe)); }