inform user in case event can't be deleted
All checks were successful
CI/CD Pipeline / test (push) Successful in 9m50s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
philipp 2024-05-21 18:34:17 +02:00
parent 02e1f77f65
commit 1bf1cc9c68

View File

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