public IHttpActionResult PutBlog(int id, Blog blog) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != blog.ID) { return BadRequest(); } _blogService.UpdateBlog(blog); try { _blogService.SaveBlog(); } catch (DbUpdateConcurrencyException) { if (!BlogExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostBlog(Blog blog) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _blogService.CreateBlog(blog); return CreatedAtRoute("DefaultApi", new { id = blog.ID }, blog); }
public void Setup() { _blog = BloggerInitializer.GetBlogs().First(); _article = BloggerInitializer.GetChsakellsArticles().First(); _formatter = new ArticleFormatter(); }