import { Request, Response } from "express";
import { FuelTypeService } from "./fuelType.service";


const fuelTypeService = new FuelTypeService();

export class FuelTypeController {

    //Obtener los datos de combustible

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

        res.json(fuelTypes);
    }

    //Obtener tipo de combustible por ID

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

        res.json(fuelType);
    }

    //Crear tipo de combustible

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

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

    //Actualizar tipo de combustible
    async update(
        req:Request,
        res:Response
    ){

        const fuelType = fuelTypeService.update(
            req.params.id as string,
            req.body
        )

        res.json(fuelType);
    }

    //Eliminar tipo de combustible
    async delete (
        req:Request,
        res:Response
    ){

        const fuelType = fuelTypeService.delete(
            req.params.id as string
        )

        res.json({
            message:"Tipo de combustible eliminado"
        });
    }
}