kolaente
3c08e18cd2
All checks were successful
the build was successful
+ Resolved quantity stuff - there now is a new table which links books or items to a quantity
25 lines
559 B
Go
25 lines
559 B
Go
package models
|
|
|
|
// AddOrUpdatePublisher adds or updates a publisher from a publisher struct
|
|
func AddOrUpdatePublisher(publisher Publisher) (newPublisher Publisher, err error) {
|
|
if publisher.ID == 0 {
|
|
if publisher.Name != "" { // Only insert it if the name is not empty
|
|
_, err = x.Insert(&publisher)
|
|
|
|
if err != nil {
|
|
return Publisher{}, err
|
|
}
|
|
}
|
|
} else {
|
|
_, err = x.ID(publisher.ID).Update(&publisher)
|
|
|
|
if err != nil {
|
|
return Publisher{}, err
|
|
}
|
|
}
|
|
|
|
newPublisher, _, err = GetPublisherByID(publisher.ID)
|
|
|
|
return newPublisher, err
|
|
}
|