TheMathemagicians/sevenkeys/logic/remove.go

28 lines
625 B
Go

package logic
import (
"database/sql"
"errors"
"sevenkeys/database"
)
var UnrecognizedStorageAreaTypeError error = errors.New("Unrecognized storage area type.")
func RemoveFromStorage(db *sql.DB, location database.LocateCardResult) error {
locationType, err := database.GetStorageAreaTypeById(db, location.CardLocationId)
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
}