71 lines
1.0 KiB
Go
71 lines
1.0 KiB
Go
package viewmodels
|
|
|
|
import (
|
|
"github.com/thewhitetulip/task/db"
|
|
"github.com/thewhitetulip/task/types"
|
|
)
|
|
|
|
func GetTasks(deleted bool) []types.Task {
|
|
return db.GetTasks(deleted)
|
|
}
|
|
|
|
func SearchTask(query string) []types.Task {
|
|
return db.SearchTask(query)
|
|
}
|
|
|
|
func AddTask(title, content string) bool {
|
|
err := db.AddTask(title, content)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func RestoreTask(id int) bool {
|
|
err := db.RestoreTask(id)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func DeleteTask(id int) bool {
|
|
err := db.DeleteTask(id)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func DeleteAll() bool {
|
|
err := db.DeleteAll()
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func ArchiveTask(id int) bool {
|
|
err := db.ArchiveTask(id)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func GetTaskById(id int) types.Task {
|
|
return db.GetTaskById(id)
|
|
}
|
|
|
|
func UpdateTask(id int, title string, content string) bool {
|
|
err := db.UpdateTask(id, title, content)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func Close() {
|
|
db.Close()
|
|
}
|