public async Task <IActionResult> PutHangHoa([FromRoute] int id, [FromBody] HangHoa hangHoa) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != hangHoa.MaHh) { return(BadRequest()); } _context.Entry(hangHoa).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HangHoaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutLoai(int id, Loai loai) { if (id != loai.MaLoai) { return(BadRequest()); } _context.Entry(loai).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoaiExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }