diff --git a/pkg/database/funcs.go b/pkg/database/funcs.go index 2f68f2f..104bb95 100644 --- a/pkg/database/funcs.go +++ b/pkg/database/funcs.go @@ -151,6 +151,11 @@ func (c *Conn) OrderServices(ctx context.Context, ids []int) error { return err } +func (c *Conn) RemoveService(ctx context.Context, id int) error { + _, err := c.Exec(ctx, "select remove_service($1)", id) + return err +} + func (tx *Tx) AddSurroundingsHighlight(ctx context.Context, companyID int, mediaID int, name string, description string) (int, error) { return tx.GetInt(ctx, "select add_surroundings_highlight($1, $2, $3, $4)", companyID, mediaID, name, description) } diff --git a/pkg/services/admin.go b/pkg/services/admin.go index a5c4b68..238496f 100644 --- a/pkg/services/admin.go +++ b/pkg/services/admin.go @@ -245,7 +245,9 @@ func deleteService(w http.ResponseWriter, r *http.Request, user *auth.User, conn http.Error(w, err.Error(), http.StatusForbidden) return } - conn.MustExec(r.Context(), "select remove_service($1)", id) + if err := conn.RemoveService(r.Context(), id); err != nil { + panic(err) + } httplib.Redirect(w, r, "/admin/services", http.StatusSeeOther) }