예제 #1
0
        public BookDTO Update(int bookId, InsertBookDTO book)
        {
            var bookToUpdate = this.mapper.Map <Book>(book);

            bookToUpdate.Id = bookId;
            var bookToReturn = this.bookRepo.Update(bookToUpdate);

            return(this.mapper.Map <BookDTO>(bookToReturn));
        }
예제 #2
0
        public BookDTO Insert(InsertBookDTO bookDTO)
        {
            Book book = mapper.Map <Book>(bookDTO);

            book.OwnerId = this.sessionService.UserId.Value;
            Book dbBook = bookRepo.Insert(book);

            return(mapper.Map <BookDTO>(dbBook));
        }
 public IActionResult Insert([FromBody] InsertBookDTO book)
 {
     if (ModelState.IsValid)
     {
         return(Ok(bookService.Insert(book)));
     }
     else
     {
         return(BadRequest(ModelState));
     }
 }
 public IActionResult Update([FromQuery] int bookId, [FromBody] InsertBookDTO book)
 {
     if (ModelState.IsValid)
     {
         return(Ok(bookService.Update(bookId, book)));
     }
     else
     {
         return(BadRequest(ModelState));
     }
 }