'use strict';

const generateControllers = require('../../core/controllers');
const eventQuestionService = require('./events_questions.service');
const { buildContext } = require('../../core/controllers');


// Module Name
const MODULE_NAME = '[eventQuestion.controller]';

const controllerOptions = { MODULE_NAME };
const extraControllers = {
    deleteQuestionsByUser: async (req, res, next) => {
        try {
            const context = {};

            const user = {
                id: req.body.id,
                phone: req.body.phone,
                email: req.body.email,
            };

            await eventQuestionService.delete({
                query: { userId: user.id }
            }, context);

            next();
        } catch (error) {
            console.error(error);
        }
    }
};

module.exports = generateControllers(eventQuestionService, extraControllers, controllerOptions);

