@RequestMapping(value = "/orders/{orderNumber}", method = RequestMethod.POST) public String updateOrder( @ModelAttribute("order") Order order, BindingResult result, Model model, RedirectAttributes redirectAttributes) { Order persistedOrder = orderService.updateOrder(order); this.sendOrderStatusUpdateEmail(persistedOrder); logger.debug("Updated order with orderNumber : {}", persistedOrder.getOrderNumber()); redirectAttributes.addFlashAttribute("info", "Order updated successfully"); return "redirect:/orders"; }
protected void sendOrderStatusUpdateEmail(Order order) { try { // Prepare the evaluation context final Context ctx = new Context(); ctx.setVariable("order", order); // Create the HTML body using Thymeleaf final String htmlContent = this.templateEngine.process("order-status-update-email", ctx); emailService.sendEmail( order.getCustomer().getEmail(), "QuilCartCart - Order Status Update", htmlContent); } catch (JCartException e) { logger.error(e); } }