Ejemplo n.º 1
0
func batchinsert(w http.ResponseWriter, r *http.Request) {
	var newScore model.Score

	c := appengine.NewContext(r)

	no, _ := strconv.Atoi(r.FormValue("no"))
	name := template.HTMLEscapeString(r.FormValue("name"))
	japanese, _ := strconv.Atoi(r.FormValue("japanese"))
	math, _ := strconv.Atoi(r.FormValue("math"))
	english, _ := strconv.Atoi(r.FormValue("english"))

	// データを生成
	newScore.Set(no, name, japanese, math, english)

	// データを登録
	if err := newScore.AddScore(c); err != nil {
		systemError(w, err)
		return
	}

}
Ejemplo n.º 2
0
func add(w http.ResponseWriter, r *http.Request) {
	var newScore model.Score

	c := appengine.NewContext(r)

	// パラメータチェック(エラーは無視)
	no, _ := strconv.Atoi(r.FormValue("no"))
	name := template.HTMLEscapeString(r.FormValue("name"))
	japanese, _ := strconv.Atoi(r.FormValue("japanese"))
	math, _ := strconv.Atoi(r.FormValue("math"))
	english, _ := strconv.Atoi(r.FormValue("english"))

	// データを生成
	newScore.Set(no, name, japanese, math, english)

	// データを登録
	if err := newScore.AddScore(c); err != nil {
		systemError(w, err)
		return
	}

	// トップページにリダイレクト
	http.Redirect(w, r, "/", http.StatusSeeOther)
}