pub async fn delete_item(list_id: i32, user_id: i32, item_id: i32, 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::owned_by_list(item_id, list_id, conn)
            && Item::delete_item(item_id, conn) {
            ResponseWithStatus::with(Status::Ok.code, constants::MESSAGE_DELETE_ITEM_SUCCESS)
        } else {
            ResponseWithStatus::with(Status::BadRequest.code, constants::MESSAGE_DELETE_ITEM_FAILED)
        }
    }).await
}
/// Attempts to delete the item with the given `item_id`. First, ensures that the user has access to the containing list
Attempts to delete the item with the given `item_id`. First, ensures that the user has access to the containing list
Attempts to delete the item with the given ` item_id ` . First ensures that the user has access to the containing list
pub async fn delete_item(list_id: i32, user_id: i32, item_id: i32, 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::owned_by_list(item_id, list_id, conn)
            && Item::delete_item(item_id, conn) {
            ResponseWithStatus::with(Status::Ok.code, constants::MESSAGE_DELETE_ITEM_SUCCESS)
        } else {
            ResponseWithStatus::with(Status::BadRequest.code, constants::MESSAGE_DELETE_ITEM_FAILED)
        }
    }).await
}
pub async fn delete_item ( list_id : i32 , user_id : i32 , item_id : i32 , 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 :: owned_by_list ( item_id , list_id , conn ) && Item :: delete_item ( item_id , conn ) { ResponseWithStatus :: with ( Status :: Ok . code , constants :: MESSAGE_DELETE_ITEM_SUCCESS ) } else { ResponseWithStatus :: with ( Status :: BadRequest . code , constants :: MESSAGE_DELETE_ITEM_FAILED ) } } ) . await }
Attempts to delete the item with the given `item_id`.
Attempts to delete the item with the given ` item_id ` .
list_id
i32
user_id
i32
item_id
i32
db
PostgresDbConn
list_id
i32
user_id
i32
item_id
i32
db
PostgresDbConn