Can delete a reservation
This commit is contained in:
@@ -86,3 +86,16 @@ pub async fn full_list(m: FamilyInPath) -> HttpResult {
|
||||
pub async fn get_single(m: FamilyAndAccommodationReservationInPath) -> HttpResult {
|
||||
Ok(HttpResponse::Ok().json(m.to_reservation()))
|
||||
}
|
||||
|
||||
/// Delete a reservation
|
||||
pub async fn delete(m: FamilyAndAccommodationReservationInPath) -> HttpResult {
|
||||
if m.membership().user_id() != m.user_id() {
|
||||
return Ok(
|
||||
HttpResponse::BadRequest().json("Only the owner of a reservation can delete it!")
|
||||
);
|
||||
}
|
||||
|
||||
accommodations_reservations_service::delete(m.to_reservation()).await?;
|
||||
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user