/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.arrebol.taxiservicios.services.catalog;

import com.arrebol.taxiservicios.beans.TaxiGenericBean;
import com.arrebol.taxiservicios.controller.catalog.CarBrandController;
import com.arrebol.taxiservicios.controller.catalog.ModelVehicleController;
import com.arrebol.taxiservicios.model.catalog.Brand;
import com.arrebol.taxiservicios.model.catalog.Vehicle;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Named;

/**
 *
 * @author oscarvargas
 */
@Named("modelVehicleService")
@ViewScoped
public class ModelVehicleService extends TaxiGenericBean implements Serializable{
    
    public List<Vehicle> fillDatatableModelVehicle() {

        return vehicleCtrl.fillModelVehicleDatatable();
    }

    public void saveModelVehicleService(Vehicle color, String brandId) {

        vehicleCtrl.saveModelVehicle(color, getLoggedUser().getId(), brandId);
    }

    public void deleteModelVehicleService(Vehicle color) {

        vehicleCtrl.deleteModelVehicle(color);
    }
    
    public List<Brand> getBrandesToVehicle() {
        return brandCtrl.fillCarBrandComboBox();
    }
    
    private static final long serialVersionUID = 2133746723187005329L;
    
    private ModelVehicleController vehicleCtrl;
    private CarBrandController brandCtrl;

    @PostConstruct
    public void init() {
        vehicleCtrl = new ModelVehicleController();
        brandCtrl = new CarBrandController();
    }
    
}
