import { Request, Response} from "express";
import { FuelPumpService } from "./fuelPump.service";

const fuelPumpService = new FuelPumpService();

export class FuelPumpController {

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

        res.json(fuelPumps);
    }

    async getById(
        req:Request,
        res:Response
    ){
        const fuelPump = await fuelPumpService.getById(
            req.params.id as string
        );
        
        res.json(fuelPump)
    }

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

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

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

        res.json(fuelPump);
    }

    async delete(
        req:Request,
        res:Response
    ){
        const fuelPump = await fuelPumpService.delete(
            req.params.id as string
        )

        res.json({
            message:"Bomba de combustible eliminada"
        });
    }
}