public IHttpActionResult GetPriceListStack(string catalog, string currency = null, [FromUri] string[] tags = null) { var evaluationContext = new Domain.Pricing.Model.PriceEvaluationContext() { CatalogId = catalog, Currency = currency != null ? (CurrencyCodes?)Enum.Parse(typeof(CurrencyCodes), currency) : null, CertainDate = DateTime.UtcNow, Tags = tags }; var strTags = tags != null ? String.Join(":", tags) : string.Empty; var cacheKey = CacheKey.Create("MP", "GetPriceListStack", catalog, currency, strTags); var retVal = _cacheManager.Get(cacheKey, () => _pricingService.EvaluatePriceLists(evaluationContext).Select(x=>x.Id).ToArray()); return this.Ok(retVal); }
public void Can_return_pricelists() { var evalContext = new Domain.Pricing.Model.PriceEvaluationContext { ProductIds = new[] { "4ed55441810a47da88a483e5a1ee4e94" } }; var pricingService = GetPricingService(GetPricingRepository); var priceLists = pricingService.EvaluatePriceLists(evalContext); Assert.True(priceLists.Count() > 0); var prices = pricingService.EvaluateProductPrices(evalContext); Assert.True(prices.Count() > 0); }
protected virtual void IndexItemPrices(ref ResultDocument doc, CatalogProduct item) { var evalContext = new Domain.Pricing.Model.PriceEvaluationContext { ProductIds = new[] { item.Id } }; var prices = _pricingService.EvaluateProductPrices(evalContext); foreach (var price in prices) { //var priceList = price.Pricelist; doc.Add(new DocumentField(string.Format("price_{0}_{1}", price.Currency, price.PricelistId).ToLower(), price.EffectiveValue, new[] { IndexStore.No, IndexType.NotAnalyzed })); doc.Add(new DocumentField(string.Format("price_{0}_{1}_value", price.Currency, price.PricelistId).ToLower(), (price.EffectiveValue).ToString(CultureInfo.InvariantCulture), new[] { IndexStore.Yes, IndexType.NotAnalyzed })); } }
public IHttpActionResult GetPriceListStack(string catalog, string currency = null, [FromUri] string[] tags = null) { var evaluationContext = new Domain.Pricing.Model.PriceEvaluationContext() { CatalogId = catalog, Currency = currency != null ? (CurrencyCodes?)Enum.Parse(typeof(CurrencyCodes), currency) : null, CertainDate = DateTime.UtcNow, Tags = tags }; var strTags = tags != null?String.Join(":", tags) : string.Empty; var cacheKey = CacheKey.Create("MP", "GetPriceListStack", catalog, currency, strTags); var retVal = _cacheManager.Get(cacheKey, () => _pricingService.EvaluatePriceLists(evaluationContext).Select(x => x.Id).ToArray()); return(this.Ok(retVal)); }
public IHttpActionResult GetProductPrices([FromUri] string[] priceLists, [FromUri] string[] products) { var retVal = new List<Price>(); var evalContext = new Domain.Pricing.Model.PriceEvaluationContext() { ProductIds = products, PricelistIds = priceLists }; var strProducts = priceLists != null ? String.Join(":", priceLists) : string.Empty; var strPriceLists = products != null ? String.Join(":", products) : string.Empty; var cacheKey = CacheKey.Create("MP", "GetProductPrices", strProducts, strPriceLists); var prices = _cacheManager.Get(cacheKey, () => _pricingService.EvaluateProductPrices(evalContext)); retVal.AddRange(prices.Select(x => x.ToWebModel())); return Ok(retVal); }
public IHttpActionResult GetProductPrices([FromUri] string[] priceLists, [FromUri] string[] products) { var retVal = new List <Price>(); var evalContext = new Domain.Pricing.Model.PriceEvaluationContext() { ProductIds = products, PricelistIds = priceLists }; var strProducts = priceLists != null?String.Join(":", priceLists) : string.Empty; var strPriceLists = products != null?String.Join(":", products) : string.Empty; var cacheKey = CacheKey.Create("MP", "GetProductPrices", strProducts, strPriceLists); var prices = _cacheManager.Get(cacheKey, () => _pricingService.EvaluateProductPrices(evalContext)); retVal.AddRange(prices.Select(x => x.ToWebModel())); return(Ok(retVal)); }
protected virtual void IndexItemPrices(ref ResultDocument doc, CatalogProduct item) { var evalContext = new Domain.Pricing.Model.PriceEvaluationContext { ProductIds = new[] { item.Id } }; var prices = _pricingService.EvaluateProductPrices(evalContext); foreach (var price in prices) { //var priceList = price.Pricelist; doc.Add(new DocumentField(string.Format("price_{0}_{1}", price.Currency, price.PricelistId), price.EffectiveValue, new[] { IndexStore.No, IndexType.NotAnalyzed })); doc.Add(new DocumentField(string.Format("price_{0}_{1}_value", price.Currency, price.PricelistId), (price.EffectiveValue).ToString(CultureInfo.InvariantCulture), new[] { IndexStore.Yes, IndexType.NotAnalyzed })); } }