package tysc

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 showIndexPage(c *gin.Context) {
	util.Render(c, gin.H{"title": "TradeYourSportsCards", "payload": nil}, "tysc/index.html")
}

func showSportList(c *gin.Context) {
	var dao = SportDAO{Db: dao.KontorDb}
	if sports, err := dao.FindAll(); err == nil {
		util.Render(c, gin.H{"title": "TYSC Sport List", "payload": sports}, "tysc/sports.html")
	} else {
		c.AbortWithError(http.StatusNotFound, err)
	}
}
