29 lines
748 B
Go
29 lines
748 B
Go
package comics
|
|
|
|
import (
|
|
"gitlab.thpeetz.de/kontor/kontor-go/pkg/dao"
|
|
"gitlab.thpeetz.de/kontor/kontor-go/pkg/util"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func showComicList(c *gin.Context) {
|
|
var dao = ComicDAO{Db: dao.KontorDb}
|
|
if comics, err := dao.FindAll(); err == nil {
|
|
util.Render(c, gin.H{"title": "Comics", "payload": comics}, "comics.html")
|
|
} else {
|
|
c.AbortWithError(http.StatusNotFound, err)
|
|
}
|
|
}
|
|
|
|
func showComic(c *gin.Context) {
|
|
var dao = ComicDAO{Db: dao.KontorDb}
|
|
comicID := c.Param("comic_id")
|
|
if comic, err := dao.FindByID(comicID); err == nil {
|
|
util.Render(c, gin.H{"title": "Comic Details", "payload": comic, "action": util.SaveAction}, "comic.html")
|
|
} else {
|
|
c.AbortWithError(http.StatusNotFound, err)
|
|
}
|
|
}
|