protected Money?GetItemPrice(CatalogEntryDto.CatalogEntryRow entry, LineItem lineItem, CustomerContact customerContact) { Currency currency = new Currency(lineItem.Parent.Parent.BillingCurrency); List <CustomerPricing> customerPricing = new List <CustomerPricing>(); customerPricing.Add(CustomerPricing.AllCustomers); if (customerContact != null) { var userKey = _mapUserKey.ToUserKey(customerContact.UserId); if (userKey != null && !string.IsNullOrWhiteSpace(userKey.ToString())) { customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.UserName, userKey.ToString())); } if (!string.IsNullOrEmpty(customerContact.EffectiveCustomerGroup)) { customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.PriceGroup, customerContact.EffectiveCustomerGroup)); } } IPriceService priceService = ServiceLocator.Current.GetInstance <IPriceService>(); PriceFilter priceFilter = new PriceFilter() { Currencies = new List <Currency>() { currency }, Quantity = lineItem.Quantity, CustomerPricing = customerPricing, ReturnCustomerPricing = false // just want one value }; // Get the lowest price among all the prices matching the parameters IPriceValue priceValue = priceService .GetPrices(lineItem.Parent.Parent.MarketId, FrameworkContext.Current.CurrentDateTime, new CatalogKey(entry), priceFilter) .OrderBy(pv => pv.UnitPrice) .FirstOrDefault(); if (priceValue != null) { return(priceValue.UnitPrice); } if (lineItem.PlacedPrice != 0) { return(new Money(lineItem.PlacedPrice, currency)); } return(null); }
public override Money?GetPlacedPrice( EntryContentBase entry, decimal quantity, CustomerContact customerContact, MarketId marketId, Currency currency) { var customerPricing = new List <CustomerPricing> { CustomerPricing.AllCustomers }; if (customerContact != null) { var userKey = _mapUserKey.ToUserKey(customerContact.UserId); if (userKey != null && !string.IsNullOrWhiteSpace(userKey.ToString())) { customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.UserName, userKey.ToString())); } if (!string.IsNullOrEmpty(customerContact.EffectiveCustomerGroup)) { customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.PriceGroup, customerContact.EffectiveCustomerGroup)); } } var priceFilter = new PriceFilter { Currencies = new List <Currency> { currency }, Quantity = quantity, CustomerPricing = customerPricing, ReturnCustomerPricing = false }; var priceValue = _priceService .GetPrices(marketId, DateTime.UtcNow, new CatalogKey(entry.Code), priceFilter) .OrderBy(pv => pv.UnitPrice) .FirstOrDefault(); return(priceValue?.UnitPrice); }
private string GetLoginEmailFromContact(CustomerContact customerContact) { return(_mapUserKey.ToUserKey(customerContact?.UserId)?.ToString()); }