Пример #1
0
        public IActionResult Post([FromBody] AuthorRequestBody body)
        {
            var author = authorService.Add(body.MapTo <AuthorToAddOrUpdate>());

            return(this.CreateHalResponse(author.MapTo <AuthorResponseBody>())
                   .AddLink(LinkTemplates.Author.Self)
                   .AddLocationHeader(this, author.Id)
                   .ToActionResult(this, HttpStatusCode.Created));
        }
Пример #2
0
        public IActionResult Put(int id, [FromBody] AuthorRequestBody body)
        {
            var author = authorService.Update(id, body.MapTo <AuthorToAddOrUpdate>());

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

            return(this.CreateHalResponse(author.MapTo <AuthorResponseBody>())
                   .AddLink(LinkTemplates.Author.Self)
                   .ToActionResult(this));
        }