if (user.getRestaurant() != null) {
if (req.getParameter("orderId") != null && !req.getParameter("orderId").isEmpty()) {
try {
YFOrder order = orderService.getOrderById(Long.parseLong(req.getParameter("orderId")));
if (order.getStatus().equals(YFOrderState.PREPARATION)) {
order.setStatus(YFOrderState.READY);
} else {
order.setStatus(YFOrderState.PREPARATION);
}
orderService.updateOrder(order);
if (order.getStatus().equals(YFOrderState.READY)) {
YFEvent event = new YFEvent();
event.setDone(false);
event.setMessage("Plat " + order.getProduct().getName() + " pour la table " + order.getTable().getName() + " prêt à être servit");
event.setTable(order.getTable());
event.setOrder(order);
eventService.createEvent(event);
}
resp.getWriter().print("{\"success\":true}");