Fix 404 & clean code

This commit is contained in:
William Bouzourène 2025-01-20 15:40:03 +01:00
parent 6b27dd545a
commit 68edf0a76f
9 changed files with 192 additions and 184 deletions

View file

@ -307,14 +307,14 @@ func ContactEdit(c *fiber.Ctx) error {
var person models.Person
result := db.Find(&person, "id = ?", id)
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return fiber.NewError(fiber.StatusNotFound, "Not found")
}
if result.Error != nil {
return result.Error
}
if result.RowsAffected < 1 {
return fiber.NewError(fiber.StatusNotFound, "Not found")
}
title := fmt.Sprintf(
"%s %s | Modifier contact",
person.LastName,
@ -549,14 +549,14 @@ func ContactConvert(c *fiber.Ctx) error {
var person models.Person
result := db.Find(&person, "id = ?", id)
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return fiber.NewError(fiber.StatusNotFound, "Not found")
}
if result.Error != nil {
return result.Error
}
if result.RowsAffected < 1 {
return fiber.NewError(fiber.StatusNotFound, "Not found")
}
person.IsContact = false
person.IsMember = true