public async Task <IActionResult> Edit(int id, [Bind("ID,MaNhaKho,TenNhaKho,DiaChi,SoDienThoai,TrangThai")] tb_WMS_NhaKho tb_WMS_NhaKho) { if (id != tb_WMS_NhaKho.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tb_WMS_NhaKho); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!tb_WMS_NhaKhoExists(tb_WMS_NhaKho.ID)) { return(NotFound()); } else { throw; } } TempData["success"] = "success"; return(RedirectToAction(nameof(Index))); } return(View(tb_WMS_NhaKho)); }
public async Task <IActionResult> Create([Bind("ID,MaNhaKho,TenNhaKho,DiaChi,SoDienThoai,TrangThai")] tb_WMS_NhaKho tb_WMS_NhaKho) { if (ModelState.IsValid) { var idend = (from u in _context.tb_WMS_NhaKho orderby u.ID descending select u.ID).Take(1).FirstOrDefault(); tb_WMS_NhaKho.ID = idend + 1; tb_WMS_NhaKho.MaNhaKho = "WH" + (idend + 1); tb_WMS_NhaKho.TrangThai = true; TempData["success"] = "success"; _context.Add(tb_WMS_NhaKho); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tb_WMS_NhaKho)); }