// PUT api/TheLoai/5 public IHttpActionResult PutTheLoai(long id, TheLoai theloai) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != theloai.TheLoaiId) { return BadRequest(); } db.Entry(theloai).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TheLoaiExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostTheLoai(TheLoai theloai) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.TheLoais.Add(theloai); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = theloai.TheLoaiId }, theloai); }