Exemplo n.º 1
0
 public IHttpActionResult Post(BlogPost blogPost)
 {
     if (blogPost == null)
     {
         return(BadRequest("Missing Blog Post"));
     }
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     if (blogPost.Id == 0)
     {
         _blogPostService.AddBlog(blogPost);
         return(Created("/Blog" + blogPost.Id, blogPost));
     }
     else
     {
         _blogPostService.EditBlogPost(blogPost);
         return(Ok(blogPost));
     }
 }