Esempio n. 1
0
        public IActionResult PartiallyUpdateBook(Guid authorId, Guid bookId, JsonPatchDocument <BookForUpdataDto> patchDocument)
        {
            if (!AuthorRepository.IsAuthorExists(authorId))
            {
                return(NotFound());
            }
            var book = BookRepository.GetBookForAuthor(authorId, bookId);

            if (book == null)
            {
                return(NotFound());
            }
            var bookToPatch = new BookForUpdataDto
            {
                Title       = book.Title,
                Description = book.Description,
                Pages       = book.Pages
            };

            patchDocument.ApplyTo(bookToPatch);
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            BookRepository.UpadataBook(authorId, bookId, bookToPatch);
            return(NoContent());
        }
Esempio n. 2
0
        public void UpadateBook(Guid authorId, Guid bookId, BookForUpdataDto book)
        {
            var originalBook = GetBookForAuthor(authorId, bookId);

            originalBook.Title       = book.Title;
            originalBook.Pages       = book.Pages;
            originalBook.Description = book.Description;
        }
Esempio n. 3
0
        public IActionResult UpdataBokk(Guid authorId, Guid bookId, BookForUpdataDto updatebook)
        {
            if (!AuthorRepository.IsAuthorExists(authorId))
            {
                return(NotFound());
            }
            var book = BookRepository.GetBookForAuthor(authorId, bookId);

            if (book == null)
            {
                return(NotFound());
            }
            BookRepository.UpadataBook(authorId, bookId, updatebook);
            return(NoContent());
        }