Ejemplo n.º 1
0
func (t *TypesController) CreateTypeHandler(c *gin.Context) {
	body := utils.GetBody(c)
	typeName := body["name"]

	app := c.MustGet("app").(models.JSON)

	d := db.NewAppsDbService(c.MustGet("user").(string))
	d.UpdateId(app["_id"],
		models.JSON{
			"$push": models.JSON{
				"types": typeName,
			},
		},
	)
}
Ejemplo n.º 2
0
func (t *TypesController) UpdateTypeItemById(c *gin.Context) {
	appId := c.Param("appId")
	typeName := c.Param("typeName")
	itemId := c.Param("itemId")

	d := db.NewTypeDbService(appId, typeName)
	body := utils.GetBody(c)

	err := d.UpdateId(itemId, body)

	if err != nil {
		RestError(c, err)
		return
	}
}
Ejemplo n.º 3
0
func (a *ApplicationController) UpdateApplicationHandler(c *gin.Context) {
	appId := c.MustGet("app").(models.JSON)["_id"]
	d := db.NewAppsDbService(c.MustGet("user").(string))
	doc := utils.WhitelistFields([]string{"name"}, utils.GetBody(c))

	err := d.Update(models.JSON{
		"_id": appId,
	}, models.JSON{
		"$set": doc,
	})

	if err != nil {
		RestError(c, err)
		return
	}
}
Ejemplo n.º 4
0
func (t *TypesController) InsertInTypeHandler(c *gin.Context) {
	appId := c.Param("appId")
	typeName := c.Param("typeName")
	body := utils.GetBody(c)

	d := db.NewTypeDbService(appId, typeName)
	err := d.Insert(body)

	if err != nil {
		RestError(c, err)
		return
	}

	notification.Notify(notification.Build(
		notification.OP_CREATE,
		notification.ORIGIN_API,
		body,
		nil,
	))

	RespondId(body["_id"], c)
}