Exemplo n.º 1
0
// TeamDelete removes a specific team.
func TeamDelete(c *gin.Context) {
	record := session.Team(c)

	err := store.DeleteTeam(
		c,
		record,
	)

	if err != nil {
		logrus.Warnf("Failed to delete team. %s", err)

		c.JSON(
			http.StatusBadRequest,
			gin.H{
				"status":  http.StatusBadRequest,
				"message": "Failed to delete team",
			},
		)

		c.Abort()
		return
	}

	c.JSON(
		http.StatusOK,
		gin.H{
			"status":  http.StatusOK,
			"message": "Successfully deleted team",
		},
	)
}
Exemplo n.º 2
0
// TeamShow retrieves a specific team.
func TeamShow(c *gin.Context) {
	record := session.Team(c)

	c.JSON(
		http.StatusOK,
		record,
	)
}
Exemplo n.º 3
0
// TeamUpdate updates an existing team.
func TeamUpdate(c *gin.Context) {
	record := session.Team(c)

	if err := c.BindJSON(&record); err != nil {
		logrus.Warnf("Failed to bind team data. %s", err)

		c.JSON(
			http.StatusPreconditionFailed,
			gin.H{
				"status":  http.StatusPreconditionFailed,
				"message": "Failed to bind team data",
			},
		)

		c.Abort()
		return
	}

	err := store.UpdateTeam(
		c,
		record,
	)

	if err != nil {
		logrus.Warnf("Failed to update team. %s", err)

		c.JSON(
			http.StatusBadRequest,
			gin.H{
				"status":  http.StatusBadRequest,
				"message": err.Error(),
			},
		)

		c.Abort()
		return
	}

	c.JSON(
		http.StatusOK,
		record,
	)
}