public async Task <IActionResult> PutPhonghoc(Phonghoc phonghoc) { //if (id != phonghoc.Maphong) //{ // return BadRequest(); //} _context.Entry(phonghoc).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { //if (!PhonghocExists(id)) //{ // return NotFound(); //} //else //{ // throw; //} } return(NoContent()); }
public async Task <ActionResult <Phonghoc> > PostPhonghoc([FromBody] Phonghoc phonghoc) { _context.Phonghoc.Add(phonghoc); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (PhonghocExists(phonghoc.Maphong)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetPhonghoc", new { id = phonghoc.Maphong }, phonghoc)); }