func (p *postgres) InsertReservation(res *models.Reservation) (int, error) {
	ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
	defer cancel()

	var newID int

	query := `INSERT INTO reservations (first_name, last_name, email, phone,
			  start_date, end_date, laptop_id, created_at, updated_at)
			  VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
			  RETURNING id`

	err := p.DB.QueryRowContext(ctx, query,
		res.FirstName,
		res.LastName,
		res.Email,
		res.Phone,
		res.StartDate,
		res.EndDate,
		res.LaptopID,
		time.Now(),
		time.Now(),
	).Scan(&newID)

	if err != nil {
		return 0, err
	}

	return newID, nil
}
// InsertReservation inserts a reservation into the database
InsertReservation inserts a reservation into the database
// InsertReservation inserts a reservation into the database
func (p *postgres) InsertReservation(res *models.Reservation) (int, error) {
	ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
	defer cancel()
	var newID int
	query := `INSERT INTO reservations (first_name, last_name, email, phone,
			  start_date, end_date, laptop_id, created_at, updated_at)
			  VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
			  RETURNING id`
	err := p.DB.QueryRowContext(ctx, query,
		res.FirstName,
		res.LastName,
		res.Email,
		res.Phone,
		res.StartDate,
		res.EndDate,
		res.LaptopID,
		time.Now(),
		time.Now(),
	).Scan(&newID)
	if err != nil {
		return 0, err
	}
	return newID, nil
}
func ( p * postgres ) InsertReservation ( res * models . Reservation ) ( int , error ) { ctx , cancel := context . WithTimeout ( context . Background ( ) , 3 * time . Second ) defer cancel ( ) var newID int query := `INSERT INTO reservations (first_name, last_name, email, phone,
			  start_date, end_date, laptop_id, created_at, updated_at)
			  VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
			  RETURNING id` err := p . DB . QueryRowContext ( ctx , query , res . FirstName , res . LastName , res . Email , res . Phone , res . StartDate , res . EndDate , res . LaptopID , time . Now ( ) , time . Now ( ) , ) . Scan ( & newID ) if err != nil { return 0 , err } return newID , nil }
InsertReservation inserts a reservation into the database
InsertReservation inserts a reservation into the database