public async Task <ActionResult <TruongHoc> > PostTruongHoc(TruongHoc truongHoc) { _context.TruongHocs.Add(truongHoc); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTruongHoc", new { id = truongHoc.id }, truongHoc)); }
public async Task <IActionResult> PutTruongHoc(int id, TruongHoc truongHoc) { if (id != truongHoc.id) { return(BadRequest()); } _context.Entry(truongHoc).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TruongHocExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }