public IActionResult AddBlogPost([FromBody] UserBost newBlogPost)
        {
            newBlogPost.Author = Request.HttpContext.User.Identity.Name;
            var savedBlogPost = _blogPostService.AddBlogPost(newBlogPost);

            return(Created(new Uri(Urls.BlogPost.Replace("{id}", savedBlogPost.Id.ToString()), UriKind.Relative), savedBlogPost));
        }
Beispiel #2
0
        public IActionResult AddBlogPost([FromBody] BlogPost newBlogPost)
        {
            var savedBlogPost = _blogPostService.AddBlogPost(newBlogPost);

            if (savedBlogPost != null)
            {
                return(Created(new Uri(Urls.BlogPost.Replace("{id}", savedBlogPost.Id.ToString()), UriKind.Relative), savedBlogPost));
            }
            else
            {
                return(NotFound());
            }
        }