import { Request, Response } from "express";
import { FuelPriceService } from "./fuelPrices.service";

const fuelPriceService = new FuelPriceService();

export class FuelPriceController {

        async getAll(
            req:Request,
            res:Response
        ){
            const fuelPrices = await fuelPriceService.getAll();
    
            res.json(fuelPrices);
        }

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

            res.json(fuelPrice);
        }

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

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

        async update(
            req:Request,
            res:Response
        ){

            const fuelPrice = await fuelPriceService.update(
                req.params.id as string,
                req.body
            )

            res.json(fuelPrice);
        }

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

            res.json({
                message:"Precio eliminado"}
            );
        }
}
