TheMathemagicians/sevenkeys/logic/remove.go

28 lines
625 B
Go
Raw Normal View History

2024-09-12 12:37:41 +00:00
package logic
import (
"database/sql"
"errors"
"sevenkeys/database"
)
var UnrecognizedStorageAreaTypeError error = errors.New("Unrecognized storage area type.")
2024-09-13 11:32:18 +00:00
func RemoveFromStorage(db *sql.DB, location database.LocateCardResult) error {
locationType, err := database.GetStorageAreaTypeById(db, location.CardLocationId)
2024-09-12 12:37:41 +00:00
if err != nil {
return err
}
if locationType == database.StorageAreaTypeBinder {
database.RemoveFromBinder(db, location)
} else if locationType == database.StorageAreaTypeBox {
database.RemoveFromBox(db, location)
} else {
return UnrecognizedStorageAreaTypeError
}
return nil
}