34 lines
632 B
Go
34 lines
632 B
Go
package events
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"net/http"
|
|
|
|
"fr.latosa-escrima/core"
|
|
"fr.latosa-escrima/core/models"
|
|
)
|
|
|
|
func HandleDelete(w http.ResponseWriter, r *http.Request) {
|
|
uuid := r.PathValue("event_uuid")
|
|
var event models.Event
|
|
res, err := core.DB.NewDelete().
|
|
Model(&event).
|
|
Where("event_id = ?", uuid).
|
|
Returning("*").
|
|
Exec(context.Background())
|
|
if err != nil {
|
|
core.JSONError{
|
|
Status: core.Error,
|
|
Message: err.Error(),
|
|
}.Respond(w, http.StatusInternalServerError)
|
|
return
|
|
}
|
|
log.Println(res)
|
|
|
|
core.JSONSuccess{
|
|
Status: core.Success,
|
|
Message: "Event deleted.",
|
|
}.Respond(w, http.StatusOK)
|
|
}
|