public IHttpActionResult Show(int id) { var book = GetBookRepository.Show(id); if (book != null) { var output = OutputBookModel.CreateOutput(book); return(Ok(output)); } return(BadRequest("Erro ao processar a solicitaçao")); }
public IHttpActionResult AuthorsBooks(int id_author) { var books = GetBookRepository.AuthorsBooks(id_author); if (books != null) { var output = OutputBookModel.CreateOutput(books); return(Ok(output)); } return(BadRequest("Erro ao processar a solicitaçao")); }
public IHttpActionResult Update(int book_id, InputBookModel input) { var old_book = GetBookRepository.Show(book_id); if (old_book != null) { var updated_book = InputBookModel.UpdateBook(input, old_book); if (updated_book != null) { var updated = GetBookRepository.Update(updated_book); var output = OutputBookModel.CreateOutput(updated); return(Ok(output)); } } return(BadRequest("Erro ao processar a solicitaçao")); }
public IHttpActionResult Store(InputBookModel input) { var author = GetAuthorRepository.FindOne(Convert.ToInt32(input.IdAuthor)); if (author != null) { var book = GetBookRepository.Store(InputBookModel.Create(input, author)); if (book != null) { var output = OutputBookModel.CreateOutput(book); return(CreatedAtRoute("DefaultApi", new { id = output.Id }, output)); } } return(BadRequest("Erro ao processar a solicitaçao")); }