public async Task <IActionResult> ShipmentsByOrder(string orderId, DataSourceRequest command) { var order = await _orderService.GetOrderById(orderId); if (order == null) { throw new ArgumentException("No order found with the specified id"); } //a vendor should have access only to his products if (_workContext.CurrentVendor != null && !_workContext.HasAccessToOrder(order) && !await _groupService.IsStaff(_workContext.CurrentCustomer)) { return(Content("")); } if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId) { return(Content("")); } //shipments var shipmentModels = new List <ShipmentModel>(); if (_workContext.CurrentVendor != null && !await _groupService.IsStaff(_workContext.CurrentCustomer)) { var shipments = (await _shipmentService.GetShipmentsByOrder(orderId)) //a vendor should have access only to his products .Where(s => _workContext.CurrentVendor == null || _workContext.HasAccessToShipment(order, s)) .OrderBy(s => s.CreatedOnUtc) .ToList(); foreach (var shipment in shipments) { shipmentModels.Add(await _shipmentViewModelService.PrepareShipmentModel(shipment, false)); } } else { var shipments = (await _shipmentService.GetShipmentsByOrder(orderId)) .OrderBy(s => s.CreatedOnUtc) .ToList(); foreach (var shipment in shipments) { shipmentModels.Add(await _shipmentViewModelService.PrepareShipmentModel(shipment, false)); } } var gridModel = new DataSourceResult { Data = shipmentModels, Total = shipmentModels.Count }; return(Json(gridModel)); }