aboutsummaryrefslogtreecommitdiffstats
path: root/src/controllers/screening.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/controllers/screening.rs')
-rw-r--r--src/controllers/screening.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/controllers/screening.rs b/src/controllers/screening.rs
index b76ae65..9e78130 100644
--- a/src/controllers/screening.rs
+++ b/src/controllers/screening.rs
@@ -22,7 +22,7 @@ use crate::{
};
use std::result::Result;
-use rocket::{get, post};
+use rocket::{delete, get, post};
use rocket::request::{Form, FromForm};
use rocket::response::Redirect;
use rocket_contrib::{
@@ -82,3 +82,14 @@ pub fn create_screening(db: db::Connection, screening: Form<NewScreeningForm>) -
db.create_screening(dbg!(screening.room_id), dbg!(screening.film_id), date, start_time, end_time)?;
Ok(Redirect::to("/screenings"))
}
+
+#[derive(FromForm)]
+pub struct DeleteScreeningForm {
+ screening_id: i32,
+}
+
+#[delete("/", format = "application/x-www-form-urlencoded", data = "<screening>")]
+pub fn delete(db: db::Connection, screening: Form<DeleteScreeningForm>) -> Result<Redirect, Box<dyn Error>> {
+ db.delete_screening(screening.screening_id)?;
+ Ok(Redirect::to("/screenings"))
+}