import { Request, Response } from "express";

import { VehicleConfigService } from "./vehiclesConfig.service";

const vehicleConfigService = new VehicleConfigService();

export class VehicleConfigController {

    async getAll(
        req:Request,
        res:Response
    ){
        const vehicleConfigs = await vehicleConfigService.getAll();

        res.json(vehicleConfigs);
    }

    async getById(
        req:Request,
        res:Response
    ){
        const vehicleConfig = await vehicleConfigService.getById(
            req.params.id as string
        );

        res.json(vehicleConfig);
    }

    async create (
        req:Request,
        res:Response
    ){
        const vehicleConfig = await vehicleConfigService.create(
            req.body
        );

        res.status(201).json(vehicleConfig);
    }

    async update(
        req:Request,
        res:Response
    ){
        const vehicleConfig = await vehicleConfigService.update(
            req.params.id as string,
            req.body
        );

        res.json(vehicleConfig);
    }

    async delete (
        req:Request,
        res:Response
    ){
        const vehicleConfig = await vehicleConfigService.delete(
            req.params.id as string
        );

        res.json({
            messaje:"Configuración de vehículo eliminada"
        });
    }
}