ability to transfer vehicle and disable users
This commit is contained in:
@@ -45,3 +45,6 @@ func UpdatePassword(id, password string) (bool, error) {
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
func SetDisabledStatusForUser(userId string, isDisabled bool) error {
|
||||
return db.SetDisabledStatusForUser(userId, isDisabled)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/akhilrex/hammond/db"
|
||||
"github.com/akhilrex/hammond/models"
|
||||
"gorm.io/gorm/clause"
|
||||
@@ -59,6 +61,17 @@ func DeleteVehicle(vehicleId string) error {
|
||||
func ShareVehicle(vehicleId, userId string) error {
|
||||
return db.ShareVehicle(vehicleId, userId)
|
||||
}
|
||||
func TransferVehicle(vehicleId, ownerId, newUserID string) error {
|
||||
vehicleOwnerId, err := GetVehicleOwner(vehicleId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if vehicleOwnerId != ownerId {
|
||||
return fmt.Errorf("Only vehicle owner can transfer the vehicle")
|
||||
}
|
||||
|
||||
return db.TransferVehicle(vehicleId, ownerId, newUserID)
|
||||
}
|
||||
func UnshareVehicle(vehicleId, userId string) error {
|
||||
return db.UnshareVehicle(vehicleId, userId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user