Feat(ktm-booking): Initial commit
Some checks failed
ktm-booking-bot/ktm-booking-bot/pipeline/head Something is wrong with the build of this commit
Some checks failed
ktm-booking-bot/ktm-booking-bot/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
29
backend/internal/user/profilecontroller.go
Normal file
29
backend/internal/user/profilecontroller.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"gorm.io/gorm/clause"
|
||||
)
|
||||
|
||||
func (env *Env) setProfile(currUser *User, ktmTrainUsername string, ktmTrainPassword string, ktmTrainCreditCardType string, ktmTrainCreditCard string, ktmTrainCreditCardExpiry string, ktmTrainCreditCardCVV string) (*User, error) {
|
||||
profile := &Profile{
|
||||
UserID: currUser.ID,
|
||||
KtmTrainUsername: ktmTrainUsername,
|
||||
KtmTrainPassword: ktmTrainPassword,
|
||||
KtmTrainCreditCardType: ktmTrainCreditCardType,
|
||||
KtmTrainCreditCard: ktmTrainCreditCard,
|
||||
KtmTrainCreditCardExpiry: ktmTrainCreditCardExpiry,
|
||||
KtmTrainCreditCardCVV: ktmTrainCreditCardCVV,
|
||||
}
|
||||
|
||||
if err := env.DB.Clauses(clause.OnConflict{
|
||||
UpdateAll: true,
|
||||
}).Create(profile).Error; err != nil {
|
||||
log.Println("Error creating profile", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
currUser.Profile = *profile
|
||||
return currUser, nil
|
||||
}
|
||||
Reference in New Issue
Block a user