2020-07-08 11:45:01 +00:00
|
|
|
//! # Movies controller
|
|
|
|
//!
|
|
|
|
//! @author Pierre Hubert
|
|
|
|
|
|
|
|
use crate::api_data::movie_api::MovieAPI;
|
|
|
|
use crate::controllers::routes::RequestResult;
|
2021-02-05 08:11:30 +00:00
|
|
|
use crate::data::base_request_handler::BaseRequestHandler;
|
2020-07-08 11:45:01 +00:00
|
|
|
use crate::data::http_request_handler::HttpRequestHandler;
|
|
|
|
use crate::helpers::movies_helper;
|
|
|
|
|
|
|
|
/// Get the list of movies of the current user
|
|
|
|
pub fn get_list(r: &mut HttpRequestHandler) -> RequestResult {
|
|
|
|
let list = movies_helper::get_list_user(r.user_id_ref()?)?;
|
|
|
|
|
|
|
|
r.set_response(MovieAPI::for_list(&list))
|
2020-07-08 11:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Remove a movie
|
|
|
|
pub fn delete(r: &mut HttpRequestHandler) -> RequestResult {
|
2020-07-12 12:20:24 +00:00
|
|
|
let movie_id = r.post_movie_id("movieID")?;
|
|
|
|
|
|
|
|
movies_helper::delete(&movies_helper::get_info(movie_id)?)?;
|
|
|
|
|
|
|
|
r.success("Movie deleted.")
|
2020-07-08 11:45:01 +00:00
|
|
|
}
|