pub async fn add_item_to_list(list_id: i32, user_id: i32, item: ItemDTO, db: PostgresDbConn) -> ResponseWithStatus {
    db.run(move |conn| {
        if !UserList::has_list_access(list_id, user_id, conn) {
            return ResponseWithStatus::with(Status::BadRequest.code, constants::MESSAGE_NO_ACCESS);
        }

        if Item::create_item_for_list(item, list_id, conn) {
            ResponseWithStatus::with(Status::Ok.code, constants::MESSAGE_CREATE_ITEM_SUCCESS)
        } else {
            ResponseWithStatus::with(Status::BadRequest.code, constants::MESSAGE_CREATE_ITEM_FAILED)
        }
    }).await
}
/// Attempts to add the given `item` to the list with the specified `list_id`. Responds with the
/// appropriate status. Makes sure that the user with `user_id` has access to that list.
Attempts to add the given `item` to the list with the specified `list_id`. Responds with the
appropriate status. Makes sure that the user with `user_id` has access to that list.
Attempts to add the given ` item ` to the list with the specified ` list_id ` . Responds with the appropriate status . Makes sure that the user with ` user_id ` has access to that list .
pub async fn add_item_to_list(list_id: i32, user_id: i32, item: ItemDTO, db: PostgresDbConn) -> ResponseWithStatus {
    db.run(move |conn| {
        if !UserList::has_list_access(list_id, user_id, conn) {
            return ResponseWithStatus::with(Status::BadRequest.code, constants::MESSAGE_NO_ACCESS);
        }
        if Item::create_item_for_list(item, list_id, conn) {
            ResponseWithStatus::with(Status::Ok.code, constants::MESSAGE_CREATE_ITEM_SUCCESS)
        } else {
            ResponseWithStatus::with(Status::BadRequest.code, constants::MESSAGE_CREATE_ITEM_FAILED)
        }
    }).await
}
pub async fn add_item_to_list ( list_id : i32 , user_id : i32 , item : ItemDTO , db : PostgresDbConn ) -> ResponseWithStatus { db . run ( move | conn | { if ! UserList :: has_list_access ( list_id , user_id , conn ) { return ResponseWithStatus :: with ( Status :: BadRequest . code , constants :: MESSAGE_NO_ACCESS ) ; } if Item :: create_item_for_list ( item , list_id , conn ) { ResponseWithStatus :: with ( Status :: Ok . code , constants :: MESSAGE_CREATE_ITEM_SUCCESS ) } else { ResponseWithStatus :: with ( Status :: BadRequest . code , constants :: MESSAGE_CREATE_ITEM_FAILED ) } } ) . await }
Attempts to add the given `item` to the list with the specified `list_id`.
Attempts to add the given ` item ` to the list with the specified ` list_id ` .
list_id
i32
user_id
i32
item
ItemDTO
db
PostgresDbConn
list_id
i32
user_id
i32
item
ItemDTO
db
PostgresDbConn