func (repo *Repository) MakeReservation(w http.ResponseWriter, r *http.Request) {
	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
	}

	laptop, err := repo.DB.GetLaptopByID(res.LaptopID)
	if err != nil {
		repo.App.Session.Put(r.Context(), "error", "can't find laptop by ID")
		http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
		return
	}

	res.Laptop.LaptopName = laptop.LaptopName

	repo.App.Session.Put(r.Context(), "reservation", res)

	stringMap := make(map[string]string)
	stringMap["start_date"] = res.StartDate.Format("2006-01-02")
	stringMap["end_date"] = res.EndDate.Format("2006-01-02")

	data := make(map[string]interface{})
	data["reservation"] = res
	render.Template(w, r, "make-reservation.page.html", &models.TemplateData{
		Form:      forms.New(nil),
		Data:      data,
		StringMap: stringMap,
	})
}
// MakeReservation renders the make a reservation page and displays form
MakeReservation renders the make a reservation page and displays form
// MakeReservation renders the make a reservation page and displays form
func (repo *Repository) MakeReservation(w http.ResponseWriter, r *http.Request) {
	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
	}
	laptop, err := repo.DB.GetLaptopByID(res.LaptopID)
	if err != nil {
		repo.App.Session.Put(r.Context(), "error", "can't find laptop by ID")
		http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
		return
	}
	res.Laptop.LaptopName = laptop.LaptopName
	repo.App.Session.Put(r.Context(), "reservation", res)
	stringMap := make(map[string]string)
	stringMap["start_date"] = res.StartDate.Format("2006-01-02")
	stringMap["end_date"] = res.EndDate.Format("2006-01-02")
	data := make(map[string]interface{})
	data["reservation"] = res
	render.Template(w, r, "make-reservation.page.html", &models.TemplateData{
		Form:      forms.New(nil),
		Data:      data,
		StringMap: stringMap,
	})
}
func ( repo * Repository ) MakeReservation ( w http . ResponseWriter , r * http . Request ) { 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 } laptop , err := repo . DB . GetLaptopByID ( res . LaptopID ) if err != nil { repo . App . Session . Put ( r . Context ( ) , " " , " " ) http . Redirect ( w , r , " " , http . StatusTemporaryRedirect ) return } res . Laptop . LaptopName = laptop . LaptopName repo . App . Session . Put ( r . Context ( ) , " " , res ) stringMap := make ( map [ string ] string ) stringMap [ " " ] = res . StartDate . Format ( " " ) stringMap [ " " ] = res . EndDate . Format ( " " ) data := make ( map [ string ] interface { } ) data [ " " ] = res render . Template ( w , r , " " , & models . TemplateData { Form : forms . New ( nil ) , Data : data , StringMap : stringMap , } ) }
MakeReservation renders the make a reservation page and displays form
MakeReservation renders the make a reservation page and displays form