Esempio n. 1
0
func Index(env Env) (status Status, headers Headers, body Body) {

	apiProducts, err := services.AllProducts()
	if err != nil {
		panic(err)
	}

	apiBrands, err := services.AllBrands()
	if err != nil {
		panic(err)
	}

	apiUsers, err := services.GetUsers()
	if err != nil {
		panic(err)
	}

	homeViewData := &HomeViewData{
		ApiProducts: apiProducts,
		ApiBrands:   apiBrands,
		ApiUsers:    apiUsers,
	}

	mangotemplate.ForRender(env, "feeds/index", homeViewData)

	return
}
Esempio n. 2
0
func Index(env Env) (status Status, headers Headers, body Body) {

	apiBrands, err := services.AllBrands()
	if err != nil {
		panic(err)
	}

	mangotemplate.ForRender(env, "brands/index", &BrandViewData{ApiBrands: apiBrands})
	return
}
Esempio n. 3
0
func New(env Env) (status Status, headers Headers, body Body) {

	newsInput := services.NewNews()
	apiBrands, err := services.AllBrands()
	if err != nil {
		panic(err)
	}

	newsViewData := &NewsViewData{
		NewsInput: newsInput,
		ApiBrands: apiBrands,
	}

	mangotemplate.ForRender(env, "news/new", newsViewData)
	return
}
Esempio n. 4
0
func New(env Env) (status Status, headers Headers, body Body) {
	productInput := services.NewProduct()
	apiBrands, err := services.AllBrands()
	if err != nil {
		panic(err)
	}

	productViewData := &ProductViewData{
		ProductInput:  productInput,
		ApiBrands:     apiBrands,
		ApiCategories: services.GetCategories(),
	}

	mangotemplate.ForRender(env, "products/new", productViewData)
	return
}
Esempio n. 5
0
func Edit(env Env) (status Status, headers Headers, body Body) {
	newsId := env.Request().URL.Query().Get(":id")
	currentUser := services.FetchUserFromEnv(env)

	newsInput, err := services.EditNews(currentUser, newsId)
	if err != nil {
		panic(err)
	}

	apiBrands, err := services.AllBrands()
	if err != nil {
		panic(err)
	}

	newsViewData := &NewsViewData{
		NewsInput: newsInput,
		ApiBrands: apiBrands,
	}

	mangotemplate.ForRender(env, "news/edit", newsViewData)
	return
}
Esempio n. 6
0
func Edit(env Env) (status Status, headers Headers, body Body) {

	productId := env.Request().URL.Query().Get(":id")

	productInput, err := services.EditProduct(productId)
	if err != nil {
		panic(err)
	}

	apiBrands, err := services.AllBrands()
	if err != nil {
		panic(err)
	}

	productViewData := &ProductViewData{
		ProductInput:  productInput,
		ApiBrands:     apiBrands,
		ApiCategories: services.GetCategories(),
	}

	mangotemplate.ForRender(env, "products/edit", productViewData)
	return
}