func CreateNewBrand(context *api.Context) { brandStore := context.GetVar("brand_store").(*brand.BrandStore) var brand_json = make(map[string]string) if err := api.DecodeBody(context.Request, &brand_json); err != nil { context.RespondErrf(http.StatusBadRequest, "FAIL_TO_PARSE %v FROM_REQUEST_BODY %v", "brand", err) return } brand, err := brandStore.CreateNewBrand(brand_json["code_name"], brand_json["full_name"]) if err != nil { context.RespondErrf(http.StatusInternalServerError, "CREATE_NEW_BRAND: %v", err) return } context.RespondOK(brand) }
func GetAllBrands(context *api.Context) { brandStore := context.GetVar("brand_store").(*brand.BrandStore) brands, err := brandStore.GetAllBrands(nil) if err != nil { context.RespondErrf(http.StatusInternalServerError, "GET_ALL_BRAND_ERROR: %v", err) return } context.RespondOK(brands) }
func GetAllUsers(context *api.Context) { userStore := context.GetVar("user_store").(*auth.UserStore) users, err := userStore.AllUsers(nil) if err != nil { context.RespondErrf(http.StatusInternalServerError, "%v", err) return } context.RespondOK(users) }