// PUT api/Tag/5 public async Task<IHttpActionResult> PutTag(int id, Tag tag) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != tag.TagID) { return BadRequest(); } db.Entry(tag).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TagExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostTag(Tag tag) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Tags.Add(tag); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = tag.TagID }, tag); }