public MarkOrdersAsShippedViewModel GetModel(SelectedOrdersViewModel model)
        {
            var orderIds     = model.Orders.Split(',').Select(int.Parse).ToList();
            var shippedModel = new MarkOrdersAsShippedViewModel {
                Page = model.Page
            };

            if (!orderIds.Any())
            {
                return(shippedModel);
            }
            foreach (var orderId in orderIds)
            {
                shippedModel.Orders.Add(_orderService.Get(orderId));
            }
            return(shippedModel);
        }
        public List <PickingListViewModel> GetPickingList(SelectedOrdersViewModel model)
        {
            if (!model.Orders.Any())
            {
                return(new List <PickingListViewModel>());
            }

            var orderIds = model.Orders.Split(',').Select(int.Parse).ToList();
            var orders   = new List <Order>();

            if (orderIds.Any())
            {
                orders.AddRange(orderIds.Select(orderId => _orderService.Get(orderId)));
            }

            var pickingList = new List <PickingListViewModel>();

            foreach (var order in orders)
            {
                foreach (var orderline in order.OrderLines)
                {
                    var alreadyExists = pickingList.Any(x => x.ProductVariantId == orderline.ProductVariant.Id);
                    if (alreadyExists)
                    {
                        var pickingListItem = pickingList.SingleOrDefault(x => x.ProductVariantId == orderline.ProductVariant.Id);
                        if (pickingListItem != null)
                        {
                            pickingListItem.Quantity += orderline.Quantity;
                        }
                    }
                    else
                    {
                        pickingList.Add(new PickingListViewModel
                        {
                            ProductVariantId = orderline.ProductVariant.Id,
                            ProductName      = orderline.ProductVariant.DisplayName,
                            Sku      = orderline.ProductVariant.SKU,
                            Quantity = orderline.Quantity
                        });
                    }
                }
            }
            return(pickingList.OrderByDescending(x => x.Quantity).ToList());
        }
        public ViewResult CreatePickingList(SelectedOrdersViewModel model)
        {
            var pickingListModel = _bulkOrdersAdminService.GetPickingList(model);

            return(View(pickingListModel));
        }
        public ViewResult MarkOrdersAsShippedForm(SelectedOrdersViewModel model)
        {
            var shippedModel = _bulkOrdersAdminService.GetModel(model);

            return(View(shippedModel));
        }