public static MessageResult RemoveMultipleFromBatch(IUnitOfWork db,
                                                            ILogService log,
                                                            ISystemActionService systemAction,
                                                            IOrderHistoryService orderHistoryService,
                                                            IBatchManager batchManager,
                                                            long batchId,
                                                            string orderIds,
                                                            long?toBatchId,
                                                            bool?removeOnHold)
        {
            var           by         = AccessManager.UserId;
            var           wasChanged = false;
            var           hasClosed  = false;
            var           fromBatch  = db.OrderBatches.GetAsDto(batchId);
            OrderBatchDTO toBatch    = null;

            if (toBatchId.HasValue)
            {
                toBatch = db.OrderBatches.GetAsDto(toBatchId.Value);
            }

            if (fromBatch.IsClosed || (toBatch != null && toBatch.IsClosed))
            {
                if (!AccessManager.CanEditSystemInfo() && !AccessManager.IsAdmin)
                {
                    hasClosed = true;
                }
            }
            if (fromBatch.IsLocked || (toBatch != null && toBatch.IsLocked))
            {
                if (!AccessManager.IsAdmin)
                {
                    return(MessageResult.Error("Source or distination batch was locked"));
                }
            }

            var orders = db.Orders.GetFiltered(o => o.BatchId == batchId);

            if (!string.IsNullOrEmpty(orderIds) && !removeOnHold.HasValue)
            {
                var stringOrderIdList = orderIds.Split(", ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                var orderIdList       = stringOrderIdList.Select(long.Parse).ToList();
                foreach (var orderId in orderIdList)
                {
                    var order = orders.FirstOrDefault(o => o.Id == orderId);
                    if (order != null)
                    {
                        if (!hasClosed || batchManager.CanBeRemovedFromBatch(order) || AccessManager.IsAdmin)
                        {
                            order.BatchId = toBatchId;

                            batchManager.CheckRemovedOrder(db, log, systemAction, order, toBatchId, by);

                            orderHistoryService.AddRecord(order.Id, OrderHistoryHelper.AddToBatchKey, fromBatch.Id, fromBatch.Name, toBatch?.Id, toBatch?.Name, by);

                            wasChanged = true;
                        }
                    }
                }
            }
            else if (removeOnHold.HasValue && removeOnHold.Value)
            {
                var onHoldOrders = orders.Where(o => o.OnHold).ToList();
                foreach (var order in onHoldOrders)
                {
                    if (!hasClosed || batchManager.CanBeRemovedFromBatch(order))
                    {
                        order.BatchId = toBatchId;

                        batchManager.CheckRemovedOrder(db, log, systemAction, order, toBatchId, by);

                        orderHistoryService.AddRecord(order.Id, OrderHistoryHelper.AddToBatchKey, fromBatch.Id, fromBatch.Name, toBatch?.Id, toBatch?.Name, by);

                        wasChanged = true;
                    }
                }
            }

            db.Commit();

            if (!wasChanged && hasClosed)
            {
                return(MessageResult.Error("Source or distination batch was closed"));
            }
            if (!wasChanged)
            {
                return(MessageResult.Error("Order list is empty"));
            }
            return(MessageResult.Success());
        }