2024-05-30 13:32:04 +00:00
|
|
|
package logic
|
|
|
|
|
2024-05-31 19:32:44 +00:00
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"sevenkeys/database"
|
|
|
|
)
|
2024-05-30 13:32:04 +00:00
|
|
|
|
2024-05-31 19:32:44 +00:00
|
|
|
func StoreCard(db *sql.DB, storageLocation database.CardStorageLocation) error {
|
|
|
|
lastPosition, err := database.GetLastPositionInBox(db, storageLocation.StorageBox)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-05-30 13:32:04 +00:00
|
|
|
|
2024-05-31 19:32:44 +00:00
|
|
|
storageLocation.Position = lastPosition + 1
|
2024-05-30 13:32:04 +00:00
|
|
|
|
2024-05-31 19:32:44 +00:00
|
|
|
err = database.InsertCardStorageLocation(db, storageLocation)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
2024-05-30 13:32:04 +00:00
|
|
|
}
|