public async Task <IActionResult> PutLoaiTb(string id, LoaiTb loaiTb) { if (id != loaiTb.MaLoai) { return(BadRequest()); } _context.Entry(loaiTb).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoaiTbExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <LoaiTb> > PostLoaiTb(LoaiTb loaiTb) { _context.LoaiTb.Add(loaiTb); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (LoaiTbExists(loaiTb.MaLoai)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetLoaiTb", new { id = loaiTb.MaLoai }, loaiTb)); }