use sqlx::{query, PgPool};

use super::Result;

pub struct VehicleAssignement {
    event_id: i32,
    vehicle_id: i32,
}

impl VehicleAssignement {
    pub async fn create(pool: &PgPool, event_id: i32, vehicle_id: i32) -> Result<()> {
        query!(
            "INSERT INTO vehicleassignement (eventId, vehicleId) VALUES ($1, $2);",
            event_id,
            vehicle_id
        )
        .execute(pool)
        .await?;

        Ok(())
    }

    pub async fn delete(pool: &PgPool, event_id: i32, vehicle_id: i32) -> Result<()> {
        query!(
            "DELETE FROM vehicleassignement WHERE eventId = $1 AND vehicleId = $2;",
            event_id,
            vehicle_id
        )
        .execute(pool)
        .await?;

        Ok(())
    }
}
