public async Task <IActionResult> Edit(int id, [Bind("Sochungtu,Ngaylap,Tenkhachhang,Diachikhachhang,Mahang,Soluong,Dongia")] Chungtu chungtu) { if (id != chungtu.Sochungtu) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(chungtu); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ChungtuExists(chungtu.Sochungtu)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Mahang"] = new SelectList(_context.Mathangs, "Mahang", "Chitietmathang", chungtu.Mahang); return(View(chungtu)); }
public async Task <IActionResult> Create([Bind("Sochungtu,Ngaylap,Tenkhachhang,Diachikhachhang,Mahang,Soluong,Dongia")] Chungtu chungtu) { if (ModelState.IsValid) { _context.Add(chungtu); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Mahang"] = new SelectList(_context.Mathangs, "Mahang", "Chitietmathang", chungtu.Mahang); return(View(chungtu)); }