func (repo *Repository) ChooseLaptop(w http.ResponseWriter, r *http.Request) {
	exploded := strings.Split(r.RequestURI, "/")
	laptopID, err := strconv.Atoi(exploded[2])
	if err != nil {
		repo.App.Session.Put(r.Context(), "error", "invalid Laptop ID")
		http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
		return
	}
	res, ok := repo.App.Session.Get(r.Context(), "reservation").(models.Reservation)
	if !ok {
		repo.App.Session.Put(r.Context(), "error", "can't get reservation from session")
		http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
		return
	}

	res.LaptopID = laptopID
	repo.App.Session.Put(r.Context(), "reservation", res)
	http.Redirect(w, r, "/make-reservation", http.StatusSeeOther)
}
// ChooseLaptop displays list of available laptops
ChooseLaptop displays list of available laptops
// ChooseLaptop displays list of available laptops
func (repo *Repository) ChooseLaptop(w http.ResponseWriter, r *http.Request) {
	exploded := strings.Split(r.RequestURI, "/")
	laptopID, err := strconv.Atoi(exploded[2])
	if err != nil {
		repo.App.Session.Put(r.Context(), "error", "invalid Laptop ID")
		http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
		return
	}
	res, ok := repo.App.Session.Get(r.Context(), "reservation").(models.Reservation)
	if !ok {
		repo.App.Session.Put(r.Context(), "error", "can't get reservation from session")
		http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
		return
	}
	res.LaptopID = laptopID
	repo.App.Session.Put(r.Context(), "reservation", res)
	http.Redirect(w, r, "/make-reservation", http.StatusSeeOther)
}
func ( repo * Repository ) ChooseLaptop ( w http . ResponseWriter , r * http . Request ) { exploded := strings . Split ( r . RequestURI , " " ) laptopID , err := strconv . Atoi ( exploded [ 2 ] ) if err != nil { repo . App . Session . Put ( r . Context ( ) , " " , " " ) http . Redirect ( w , r , " " , http . StatusTemporaryRedirect ) return } res , ok := repo . App . Session . Get ( r . Context ( ) , " " ) . ( models . Reservation ) if ! ok { repo . App . Session . Put ( r . Context ( ) , " " , " " ) http . Redirect ( w , r , " " , http . StatusTemporaryRedirect ) return } res . LaptopID = laptopID repo . App . Session . Put ( r . Context ( ) , " " , res ) http . Redirect ( w , r , " " , http . StatusSeeOther ) }
ChooseLaptop displays list of available laptops
ChooseLaptop displays list of available laptops