public async Task <IActionResult> PutLichhoc(Lichhoc lichhoc) { //if (id != lichhoc.Malichhoc) //{ // return BadRequest(); //} _context.Entry(lichhoc).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { //if (!LichhocExists(id)) //{ // return NotFound(); //} //else //{ // throw; //} } return(NoContent()); }
public async Task <ActionResult <Lichhoc> > PostLichhoc([FromBody] Lichhoc lichhoc) { _context.Lichhoc.Add(lichhoc); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (LichhocExists(lichhoc.Malichhoc)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetLichhoc", new { id = lichhoc.Malichhoc }, lichhoc)); }