コード例 #1
0
        private void BuildPrices(FindDocument document, CatalogEntryDto.CatalogEntryRow entryRow, ISearchConfiguration configuration)
        {
            IPriceService instance   = ServiceLocator.Current.GetInstance <IPriceService>();
            CatalogKey    catalogKey = new CatalogKey(entryRow);
            HashSet <Mediachase.Commerce.Currency> source1 = new HashSet <Mediachase.Commerce.Currency>();
            HashSet <MarketId>            source2          = new HashSet <MarketId>();
            IFieldConfiguration <double?> field            = null;

            foreach (IPriceValue catalogEntryPrice in instance.GetCatalogEntryPrices(catalogKey))
            {
                HashSet <Mediachase.Commerce.Currency> currencySet = source1;
                Money unitPrice = catalogEntryPrice.UnitPrice;
                Mediachase.Commerce.Currency currency1 = unitPrice.Currency;
                if (currencySet.Add(currency1))
                {
                    ISearchConfiguration searchConfiguration = configuration;
                    unitPrice = catalogEntryPrice.UnitPrice;
                    Mediachase.Commerce.Currency currency2 = unitPrice.Currency;
                    searchConfiguration.AddCurrency(currency2);
                }
                if (source2.Add(catalogEntryPrice.MarketId))
                {
                    configuration.AddMarket(catalogEntryPrice.MarketId);
                }
                ISearchConfiguration searchConfiguration1 = configuration;
                string name = "saleprice";
                unitPrice = catalogEntryPrice.UnitPrice;
                Mediachase.Commerce.Currency currencyCode = (Mediachase.Commerce.Currency)unitPrice.Currency.CurrencyCode;
                MarketId marketId = (MarketId)catalogEntryPrice.MarketId.Value;
                ref IFieldConfiguration <double?> local = ref field;
                if (searchConfiguration1.TryGetPriceField(name, currencyCode, marketId, out local))
                {
                    unitPrice = catalogEntryPrice.UnitPrice;
                    double amount   = (double)unitPrice.Amount;
                    double?nullable = field.GetValue(document);
                    if (!nullable.HasValue || nullable.Value > amount)
                    {
                        field.SetValue(document, new double?(amount));
                    }
                }
            }
コード例 #2
0
 public SearchDocumentImplementation(ISearchConfiguration config, string locale, SearchHit <FindDocument> hit)
 {
     this._fields = new List <ISearchField>();
     this._fields.Add((ISearchField) new SearchField("_id", (object)hit.Document.CatalogEntryId));
     foreach (string language in hit.Document.Languages)
     {
         config.AddLocale(language);
     }
     foreach (string currency in hit.Document.Currencies)
     {
         config.AddCurrency((Mediachase.Commerce.Currency)currency);
     }
     foreach (string market in hit.Document.Markets)
     {
         config.AddMarket((MarketId)market);
     }
     foreach (IFieldConfiguration allField in config.GetAllFields(locale))
     {
         object obj = allField.GetObjectValue(hit.Document);
         IEnumerable <string> source = obj as IEnumerable <string>;
         if (source != null)
         {
             string[] array = source.Where <string>((Func <string, bool>)(v => v != null)).ToArray <string>();
             obj = array.Length != 0 ? (object)array : (object)(string[])null;
         }
         if (obj != null)
         {
             if (allField.Currency.HasValue)
             {
                 this._fields.Add((ISearchField) new SearchField(string.Format("{0}{1}_{2}", (object)allField.Name, (object)allField.Currency.Value.CurrencyCode, (object)allField.MarketId.Value), obj));
             }
             else
             {
                 this._fields.Add((ISearchField) new SearchField(allField.Name, obj));
             }
         }
     }
 }