add eventtitle
This commit is contained in:
28
main.go
28
main.go
@@ -13,6 +13,11 @@ import (
|
||||
|
||||
func GetDefaultTasks() []Task {
|
||||
return []Task{
|
||||
{
|
||||
Name: "Title",
|
||||
Description: ``,
|
||||
IsOptional: true,
|
||||
},
|
||||
{
|
||||
Name: "Promotion",
|
||||
Description: `
|
||||
@@ -100,17 +105,18 @@ func CreateTasklist(title string, db *sql.DB) Tasklist {
|
||||
fmt.Println(err)
|
||||
}
|
||||
defer stmt.Close()
|
||||
var promotion, opening, entering, preparekuefa, cookkuefa, cleanup, weeklytoilet string
|
||||
err = stmt.QueryRow(title).Scan(&promotion, &opening, &entering, &preparekuefa, &cookkuefa, &cleanup, &weeklytoilet)
|
||||
var eventtitle, promotion, opening, entering, preparekuefa, cookkuefa, cleanup, weeklytoilet string
|
||||
err = stmt.QueryRow(title).Scan(&eventtitle, &promotion, &opening, &entering, &preparekuefa, &cookkuefa, &cleanup, &weeklytoilet)
|
||||
|
||||
if err == nil {
|
||||
tasks[0].Value = promotion
|
||||
tasks[1].Value = opening
|
||||
tasks[2].Value = entering
|
||||
tasks[3].Value = preparekuefa
|
||||
tasks[4].Value = cookkuefa
|
||||
tasks[5].Value = cleanup
|
||||
tasks[6].Value = weeklytoilet
|
||||
tasks[0].Value = eventtitle
|
||||
tasks[1].Value = promotion
|
||||
tasks[2].Value = opening
|
||||
tasks[3].Value = entering
|
||||
tasks[4].Value = preparekuefa
|
||||
tasks[5].Value = cookkuefa
|
||||
tasks[6].Value = cleanup
|
||||
tasks[7].Value = weeklytoilet
|
||||
}
|
||||
|
||||
return Tasklist{
|
||||
@@ -129,12 +135,12 @@ func InsertToDB(tasklist Tasklist, db *sql.DB) {
|
||||
var name string
|
||||
err = stmt.QueryRow(tasklist.Title).Scan(&name)
|
||||
if err != nil {
|
||||
db.Exec("insert into tasklists(name, "+GetTaskNameString(", ")+") values(?, ?, ?, ?, ?, ?, ?, ?)", tasklist.Title, tasklist.Tasks[0].Value, tasklist.Tasks[1].Value, tasklist.Tasks[2].Value, tasklist.Tasks[3].Value, tasklist.Tasks[4].Value, tasklist.Tasks[5].Value, tasklist.Tasks[6].Value)
|
||||
db.Exec("insert into tasklists(name, "+GetTaskNameString(", ")+") values(?, ?, ?, ?, ?, ?, ?, ?, ?)", tasklist.Title, tasklist.Tasks[0].Value, tasklist.Tasks[1].Value, tasklist.Tasks[2].Value, tasklist.Tasks[3].Value, tasklist.Tasks[4].Value, tasklist.Tasks[5].Value, tasklist.Tasks[6].Value, tasklist.Tasks[7].Value)
|
||||
if err != nil {
|
||||
fmt.Println("Error during insert: ", err)
|
||||
}
|
||||
} else {
|
||||
_, err := db.Exec("update tasklists set "+GetTaskNameString(" = ?,")+" = ? where name = ?", tasklist.Tasks[0].Value, tasklist.Tasks[1].Value, tasklist.Tasks[2].Value, tasklist.Tasks[3].Value, tasklist.Tasks[4].Value, tasklist.Tasks[5].Value, tasklist.Tasks[6].Value, tasklist.Title)
|
||||
_, err := db.Exec("update tasklists set "+GetTaskNameString(" = ?,")+" = ? where name = ?", tasklist.Tasks[0].Value, tasklist.Tasks[1].Value, tasklist.Tasks[2].Value, tasklist.Tasks[3].Value, tasklist.Tasks[4].Value, tasklist.Tasks[5].Value, tasklist.Tasks[6].Value, tasklist.Tasks[7], tasklist.Title)
|
||||
if err != nil {
|
||||
fmt.Println("Error during update: ", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user