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 }
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 }
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 }
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 }
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 }
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 }