Esempio n. 1
0
func (c List) Get(id int) revel.Result {
	if id != 5 {
		return c.RenderJson(errors.NewHttpErrorWithDetails(404, "List not found"))
	}

	list := models.List{5, "Weekly shopping list", "weekly", "66", "pink", []models.ListItem{}, []models.ListProduct{}}

	return c.RenderJson(list)
}
Esempio n. 2
0
func (c List) Add() revel.Result {
	listForm := forms.List()
	form := listForm(c.Request.Request)

	if !form.IsValid() {
		return c.RenderJson(errors.NewHttpErrorWithDetails(400, fmt.Sprintf("%v", form.Errors())))
	}

	list := models.List{}
	form.MapTo(&list)

	return c.RenderJson(list)
}