module.exports = {


    friendlyName: 'Create',


    description: 'Create Attribution rang!',


    inputs: {
        anneeScolaire: {
            type: 'string',
            required: true
        },
        dateDebut: {
            type: 'string',
            required: true
        },

        dateFin: {
            type: 'string',
            required: true
        },
        
    },


    exits: {
        notFound: {
            statusCode: 404
        },
    },


    fn: async function (inputs, exits) {

        //console.log("INPUTS 1", inputs)

        let annee = await AnneeScolaire.find({ anneeScolaire: inputs.anneeScolaire}).then(_.first)
       
        if (annee) {

            return exits.notFound({ message: "Cette année scolaire existe déja, veuillez la modifier!" })
        } else {
            let anneeCreate = await AnneeScolaire.create(inputs).fetch();
            return exits.success(_.merge(anneeCreate));
        }
        // All done.
        

    }


};
