public async Task <IList <YahooDetailRow> > GetYahooDetailRowsAsync(Order order) { var result = new List <YahooDetailRow>(); var pickupLineNumber = 1; var shippingLineNumber = 1; var orderItems = await _customOrderService.GetOrderItemsAsync(order.Id); foreach (var orderItem in orderItems) { int lineNumber = GetLineNumber(ref pickupLineNumber, ref shippingLineNumber, orderItem); var product = await _productService.GetProductByIdAsync(orderItem.ProductId); var productAbcDescription = await _productAbcDescriptionService.GetProductAbcDescriptionByProductIdAsync( orderItem.ProductId ); var storeUrl = (await _storeService.GetStoreByIdAsync(order.StoreId))?.Url; var warranty = await _customOrderService.GetOrderItemWarrantyAsync(orderItem); if (warranty != null) { // adjust price for item orderItem.UnitPriceExclTax -= warranty.PriceAdjustment; } (string code, decimal price)standardItemCodeAndPrice = GetCodeAndPrice(orderItem, product, productAbcDescription); result.Add(new YahooDetailRow( _settings.OrderIdPrefix, orderItem, lineNumber, product.Sku, standardItemCodeAndPrice.code, standardItemCodeAndPrice.price, product.Name, $"{storeUrl}{await _urlRecordService.GetSeNameAsync(product)}", await GetPickupStoreAsync(orderItem) )); lineNumber++; if (warranty != null) { result.Add(new YahooDetailRow( _settings.OrderIdPrefix, orderItem, lineNumber, standardItemCodeAndPrice.code, _warrantyService.GetWarrantySkuByName(warranty.Name), warranty.PriceAdjustment, warranty.Name, "", // no url for warranty line items await GetPickupStoreAsync(orderItem) )); lineNumber++; } var freeGift = orderItem.GetFreeGift(); if (freeGift != null) { var amg = _abcMattressGiftService.GetAbcMattressGiftByDescription(freeGift); if (amg == null) { throw new Exception($"Unable to match free gift named {freeGift}"); } result.Add(new YahooDetailRow( _settings.OrderIdPrefix, orderItem, lineNumber, "", // no item ID associated amg.ItemNo, 0.00M, // free item freeGift, "", // no url for free gifts await GetPickupStoreAsync(orderItem), -1 )); lineNumber++; } var mattressProtector = orderItem.GetMattressProtector(); if (mattressProtector != null) { var size = orderItem.GetMattressSize(); var amp = _abcMattressProtectorService.GetAbcMattressProtectorsBySize(size) .Where(p => p.Name == mattressProtector) .FirstOrDefault(); if (amp == null) { throw new Exception($"Unable to match mattress protector named {mattressProtector}"); } result.Add(new YahooDetailRow( _settings.OrderIdPrefix, orderItem, lineNumber, "", // no item ID associated amp.ItemNo, amp.Price, mattressProtector, "", // no url await GetPickupStoreAsync(orderItem) )); lineNumber++; } lineNumber = await ProcessFrameAsync(orderItem, lineNumber, result); SetLineNumber(ref pickupLineNumber, ref shippingLineNumber, orderItem, lineNumber); } return(result); }