Can update accommodation information
This commit is contained in:
parent
9a4da0462a
commit
d0d1169c7d
@ -77,6 +77,24 @@ pub async fn get_single(m: FamilyAndAccommodationInPath) -> HttpResult {
|
||||
Ok(HttpResponse::Ok().json(&m.to_accommodation()))
|
||||
}
|
||||
|
||||
/// Update an accommodation
|
||||
pub async fn update(
|
||||
m: FamilyAndAccommodationInPath,
|
||||
req: web::Json<AccommodationRequest>,
|
||||
_admin: FamilyInPathWithAdminMembership,
|
||||
) -> HttpResult {
|
||||
let mut accommodation = m.to_accommodation();
|
||||
|
||||
if let Err(e) = req.0.to_accommodation(&mut accommodation).await {
|
||||
log::error!("Failed to parse accommodation information! {e}");
|
||||
return Ok(HttpResponse::BadRequest().body(e.to_string()));
|
||||
}
|
||||
|
||||
accommodations_list_service::update(&mut accommodation).await?;
|
||||
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
||||
/// Delete an accommodation
|
||||
pub async fn delete(
|
||||
m: FamilyAndAccommodationInPath,
|
||||
|
@ -218,7 +218,10 @@ async fn main() -> std::io::Result<()> {
|
||||
"/family/{id}/accommodations/list/{accommodation_id}",
|
||||
web::get().to(accommodations_list_controller::get_single),
|
||||
)
|
||||
// TODO : update
|
||||
.route(
|
||||
"/family/{id}/accommodations/list/{accommodation_id}",
|
||||
web::put().to(accommodations_list_controller::update),
|
||||
)
|
||||
.route(
|
||||
"/family/{id}/accommodations/list/{accommodation_id}",
|
||||
web::delete().to(accommodations_list_controller::delete),
|
||||
|
Loading…
Reference in New Issue
Block a user