Skip to content

Commit

Permalink
remove duplicated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
szarbartosz committed Nov 5, 2024
1 parent 21482fc commit 287ce38
Showing 1 changed file with 0 additions and 51 deletions.
51 changes: 0 additions & 51 deletions controllers/statusesController.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,6 @@ func UpdateStatus(c *gin.Context) {
c.JSON(http.StatusOK, updatedStatus)
}

func UpdateStatus(c *gin.Context) {
var body models.Status

if c.BindJSON(&body) != nil {
c.JSON(http.StatusBadRequest, gin.H{
"error": "Invalid request body",
})
return
}

result := initializers.DB.Where("id", c.Param("id")).Updates(&body)

if result.RowsAffected == 0 {
c.JSON(http.StatusInternalServerError, gin.H{
"error": "Failed to update status",
})
return
}

var updatedStatus models.Status
initializers.DB.First(&updatedStatus, c.Param("id"))

c.JSON(http.StatusOK, updatedStatus)
}

func GetStatuses(c *gin.Context) {
var statuses []models.Status

Expand Down Expand Up @@ -121,29 +96,3 @@ func DeleteStatus(c *gin.Context) {
"message": "Status deleted",
})
}

func DeleteStatus(c *gin.Context) {
var status models.Status

result := initializers.DB.First(&status, c.Param("id"))

if result.Error != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"error": "Status not found",
})
return
}

deleteResult := initializers.DB.Delete(&status)

if deleteResult.Error != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"error": "Failed to delete investor: " + deleteResult.Error.Error(),
})
return
}

c.JSON(http.StatusOK, gin.H{
"message": "Status deleted",
})
}

0 comments on commit 287ce38

Please sign in to comment.