private void PopulateVariationInfo(CatalogEntryDto.CatalogEntryRow entryRow, LineItem lineItem) { CatalogEntryDto.VariationRow variationRow = entryRow.GetVariationRows().FirstOrDefault(); if (variationRow != null) { lineItem.MaxQuantity = variationRow.MaxQuantity; lineItem.MinQuantity = variationRow.MinQuantity; CustomerContact customerContact = CustomerContext.Current.GetContactById(lineItem.Parent.Parent.CustomerId); Money? newListPrice = GetItemPrice(entryRow, lineItem, customerContact); if (newListPrice.HasValue) { Money oldListPrice = new Money(Math.Round(lineItem.ListPrice, 2), lineItem.Parent.Parent.BillingCurrency); if (oldListPrice != newListPrice.Value) { AddWarningSafe(Warnings, "LineItemPriceChange-" + lineItem.Parent.LineItems.IndexOf(lineItem).ToString(), string.Format("Price for \"{0}\" has been changed from {1} to {2}.", lineItem.DisplayName, oldListPrice.ToString(), newListPrice.ToString())); // Set new price on line item. lineItem.ListPrice = newListPrice.Value.Amount; if (lineItem.Parent.Parent.ProviderId.ToLower().Equals("frontend")) { lineItem.PlacedPrice = newListPrice.Value.Amount; } } } } }
/// <summary> /// Check catalog entry's tracking inventory was enable or not. /// </summary> /// <param name="catalogEntry">Catalog entry.</param> private bool InventoryTrackingEnabled(CatalogEntryDto.CatalogEntryRow catalogEntry) { var entryVariations = catalogEntry.GetVariationRows(); var variation = entryVariations.FirstOrDefault(); return variation != null && variation.TrackInventory; }
private static IEnumerable<CatalogEntryDto.VariationRow> GetEntryVariations(CatalogEntryDto.CatalogEntryRow catalogEntry) { if (catalogEntry == null) { throw new ArgumentNullException("catalogEntry"); } return catalogEntry.GetVariationRows(); }