Fixed: When updating a book, no title is needed
the build failed Details

This commit is contained in:
konrad 2017-11-29 15:59:34 +01:00 committed by kolaente
parent 7fba68f812
commit 3d1a710ae0
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 3 additions and 5 deletions

View File

@ -20,8 +20,8 @@ sie in die Datenbank eingetragen und mit dem Buch verknüpft.
// AddOrUpdateBook adds a new book or updates an existing one, it takes a book struct with author and publisher. Inserts them if they don't already exist
func AddOrUpdateBook(book Book) (newBook Book, err error) {
// Check if we have at least a booktitle
if book.Title == "" {
// Check if we have at least a booktitle when we're inserting a new book
if book.Title == "" && book.ID == 0{
return Book{}, fmt.Errorf("the book should at least have a title")
}
@ -35,8 +35,6 @@ func AddOrUpdateBook(book Book) (newBook Book, err error) {
}
}
fmt.Println(publisherid)
_, exists, err = GetPublisherByID(publisherid)
if err != nil {
return Book{}, err

View File

@ -50,7 +50,7 @@ func BookAddOrUpdate(c echo.Context) error {
}
// Check if we have at least a title
if datBook.Title == "" {
if datBook.Title == "" && datBook.ID == 0 {
return c.JSON(http.StatusBadRequest, models.Message{"You need at least a title to insert a new book!"})
}