harris_paint / src /controllers /market.controller.js
aliroohan179's picture
Upload 58 files
10821c7 verified
Raw
History Blame Contribute Delete
835 Bytes
const marketService = require('../services/market.service');
exports.list = async (req, res, next) => {
try { res.json({ markets: await marketService.list() }); }
catch (error) { next(error); }
};
exports.getById = async (req, res, next) => {
try { res.json({ market: await marketService.getById(req.params.id) }); }
catch (error) { next(error); }
};
exports.update = async (req, res, next) => {
try { res.json({ market: await marketService.update(req.params.id, req.body, req.admin._id, req.ip) }); }
catch (error) { next(error); }
};
exports.toggleActive = async (req, res, next) => {
try {
const market = await marketService.toggleActive(req.params.id, req.admin._id, req.ip);
res.json({ market, message: `Market ${market.isActive ? 'activated' : 'deactivated'}.` });
} catch (error) { next(error); }
};