import {Request, Response } from "express";

import { VehicleAssigService } from "./vehicleassig.service";

const vehicleAssigService = new VehicleAssigService();

export class VehicleAssigController {

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

        const vAssigs = await vehicleAssigService.getAll();

        res.json(vAssigs);
    }

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

        const vAssig = await vehicleAssigService.getById(
            req.params.id as string
        );

        res.json(vAssig);
    }

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

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

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

        res.json(vAssig);
    }

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

        res.json({
            message:"Assignación eliminada"
        });
    }
}