diff --git a/src/tera/admin/planned_event.rs b/src/tera/admin/planned_event.rs index d198c30..18a04e9 100644 --- a/src/tera/admin/planned_event.rs +++ b/src/tera/admin/planned_event.rs @@ -78,12 +78,13 @@ async fn update( #[get("/planned-event//delete")] async fn delete(db: &State, id: i64, _admin: PlannedEventUser) -> Flash { - match PlannedEvent::find_by_id(db, id).await { - Some(planned_event) => { - planned_event.delete(db).await; - Flash::success(Redirect::to("/planned"), "Event gelöscht") - } - None => Flash::error(Redirect::to("/planned"), "PlannedEvent does not exist"), + let Some(event) = PlannedEvent::find_by_id(db, id).await else { + return Flash::error(Redirect::to("/planned"), "PlannedEvent does not exist"); + }; + + match event.delete(db).await { + Ok(()) => Flash::success(Redirect::to("/planned"), "Event gelöscht"), + Err(e) => Flash::error(Redirect::to("/planned"), e), } }