// PUT api/Admin/5 public IHttpActionResult PutBlogPost(int id, BlogPost blogPost) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != blogPost.Id) { return BadRequest(); } data.BlogPosts.Update(blogPost); try { data.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BlogPostExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostBlogPost(BlogPost blogpost) { if (!ModelState.IsValid) { return BadRequest(ModelState); } data.BlogPosts.Add(blogpost); data.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = blogpost.Id }, blogpost); }