예제 #1
0
        public IActionResult Post([FromBody] ArticleRequestBody body)
        {
            var article = articleService.Add(body.MapTo <ArticleToAddOrUpdate>());

            return(this.CreateHalResponse(article.MapTo <ArticleResponseBody>())
                   .AddLink(LinkTemplates.Article.Self)
                   .AddLocationHeader(this, article.Id)
                   .ToActionResult(this, HttpStatusCode.Created));
        }
예제 #2
0
        public IActionResult Put(int id, [FromBody] ArticleRequestBody body)
        {
            var article = articleService.Update(id, body.MapTo <ArticleToAddOrUpdate>());

            if (article == null)
            {
                return(NotFound());
            }

            return(this.CreateHalResponse(article.MapTo <ArticleResponseBody>())
                   .AddLink(LinkTemplates.Article.Self)
                   .ToActionResult(this));
        }