Admin Order Controller Action calling twice _orderService.UpdateOrder(order)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Does anyone knows why the _orderService.UpdateOrder(order) is called twice in the following Action contained in Presentation\Nop.Web\Areas\Admin\Controllers\OrderController.cs line 1034 ? I can't figure it out. In the first call is clear that we are updating the order status but what is the purpose of the second call ?

        [HttpPost, ActionName("Edit")]
        [FormValueRequired("btnSaveOrderStatus")]
        public virtual IActionResult ChangeOrderStatus(int id, OrderModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
                return AccessDeniedView();

            //try to get an order with the specified id
            var order = _orderService.GetOrderById(id);
            if (order == null)
                return RedirectToAction("List");

            //a vendor does not have access to this functionality
            if (_workContext.CurrentVendor != null)
                return RedirectToAction("Edit", "Order", new { id });

            try
            {
                order.OrderStatusId = model.OrderStatusId;
                _orderService.UpdateOrder(order);

                //add a note
                order.OrderNotes.Add(new OrderNote
                {
                    Note = $"Order status has been edited. New status: {_localizationService.GetLocalizedEnum(order.OrderStatus)}",
                    DisplayToCustomer = false,
                    CreatedOnUtc = DateTime.UtcNow
                });
                _orderService.UpdateOrder(order);
                LogEditOrder(order.Id);

                //prepare model
                model = _orderModelFactory.PrepareOrderModel(model, order);

                return View(model);
            }
            catch (Exception exc)
            {
                //prepare model
                model = _orderModelFactory.PrepareOrderModel(model, order);

                _notificationService.ErrorNotification(exc);
                return View(model);
            }
        }
4 years ago
Never mind. I got it. I didn't realize that the order note was part of the order. Thank you anyway.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.