new grpc functions
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 34s
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 34s
This commit is contained in:
@@ -144,7 +144,12 @@ func (s MemoryStorage) GetBooking(id string) (res *types.Booking, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (s MemoryStorage) UpdateBookingStatus(bookingid string, newStatus string) error {
|
||||
func (s MemoryStorage) UpdateBooking(booking types.Booking) error {
|
||||
s.Bookings[booking.Id] = &booking
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s MemoryStorage) UpdateBookingStatus(bookingid string, newStatus string, reason string) error {
|
||||
b := s.Bookings[bookingid]
|
||||
|
||||
if b == nil {
|
||||
@@ -152,6 +157,7 @@ func (s MemoryStorage) UpdateBookingStatus(bookingid string, newStatus string) e
|
||||
}
|
||||
|
||||
b.Status = newStatus
|
||||
b.Data["reason"] = reason
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -210,9 +210,18 @@ func (s MongoDBStorage) GetBooking(id string) (*types.Booking, error) {
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
func (s MongoDBStorage) UpdateBookingStatus(bookingid string, newStatus string) error {
|
||||
func (s MongoDBStorage) UpdateBooking(booking types.Booking) error {
|
||||
// filter := bson.M{"_id": bookingid}
|
||||
replacement := bson.M{"$set": bson.M{"status": newStatus}}
|
||||
if _, err := s.Collections.Bookings.ReplaceOne(context.Background(), bson.M{"_id": booking.Id}, booking); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s MongoDBStorage) UpdateBookingStatus(bookingid string, newStatus string, reason string) error {
|
||||
// filter := bson.M{"_id": bookingid}
|
||||
replacement := bson.M{"$set": bson.M{"status": newStatus, "data.reason": reason}}
|
||||
|
||||
if _, err := s.Collections.Bookings.UpdateByID(context.Background(), bookingid, replacement); err != nil {
|
||||
return err
|
||||
|
||||
@@ -23,7 +23,8 @@ type Storage interface {
|
||||
CreateBooking(types.Booking) error
|
||||
GetAllBookings() ([]*types.Booking, error)
|
||||
GetBooking(id string) (*types.Booking, error)
|
||||
UpdateBookingStatus(bookingid string, newStatus string) error
|
||||
UpdateBooking(booking types.Booking) error
|
||||
UpdateBookingStatus(bookingid string, newStatus string, reason string) error
|
||||
}
|
||||
|
||||
func NewStorage(cfg *viper.Viper) (Storage, error) {
|
||||
|
||||
Reference in New Issue
Block a user