ctx.ViewData["Title"] = "Verifying Band" name := ctx.Request.FormValue("name") loctype := ctx.Request.FormValue("loctype") var locationId string errorString := "no errors" switch loctype { case "existing": if ctx.Request.FormValue("location_id") == "" { errorString = "No location was selected" } else { locationId = ctx.Request.FormValue("location_id") } break case "new": if ctx.Request.FormValue("country") != "" { locationId = models2.GenerateId(gocbweb.LOCTYPE) location := models2.Location{ City: ctx.Request.FormValue("city"), State: ctx.Request.FormValue("state"), Country: ctx.Request.FormValue("country")} doc := models2.MyDoc{Id: locationId, Type: gocbweb.LOCTYPE, Value: location} added, err := models2.AddDoc(doc, gocbweb.LOCTYPE) if err != nil { errorString = "error on location add: " + err.Error() } if added == false { errorString = "Duplicate id: " + locationId } } else { errorString = "Country is required" }
yearString := ctx.Request.FormValue("year") year, _ := strconv.Atoi(yearString) genretype := ctx.Request.FormValue("genretype") var genreId string errorString := "no errors" switch genretype { case "existing": if ctx.Request.FormValue("genre_id") == "" { errorString = "No genre was selected" } else { genreId = ctx.Request.FormValue("genre_id") } break case "new": if ctx.Request.FormValue("genre_name") != "" { genreId = models2.GenerateId(gocbweb.GENRETYPE) genre := models2.Genre{Name: ctx.Request.FormValue("genre_name")} doc := models2.MyDoc{Id: genreId, Type: gocbweb.GENRETYPE, Value: genre} added, err := models2.AddDoc(doc, gocbweb.GENRETYPE) if err != nil { errorString = fmt.Sprintf("Genre: %s", err.Error()) } if added == false { errorString = "Duplicate id: " + genreId } } else { errorString = "Genre name is required" } break }