Пример #1
0
        public static webModel.Pricelist ToWebModel(this coreModel.Pricelist priceList, coreCatalogModel.CatalogProduct[] products = null, coreCatalogModel.Catalog[] catalogs = null, ConditionExpressionTree etalonEpressionTree = null)
        {
            var retVal = new webModel.Pricelist();

            retVal.InjectFrom(priceList);
            retVal.Currency = priceList.Currency;
            if (priceList.Prices != null)
            {
                retVal.ProductPrices = new List <webModel.ProductPrice>();
                foreach (var group in priceList.Prices.GroupBy(x => x.ProductId))
                {
                    var productPrice = new webModel.ProductPrice(group.Key, group.Select(x => x.ToWebModel()));

                    retVal.ProductPrices.Add(productPrice);
                    if (products != null)
                    {
                        var product = products.FirstOrDefault(x => x.Id == productPrice.ProductId);
                        if (product != null)
                        {
                            productPrice.ProductName = product.Name;
                        }
                    }
                }
            }
            if (priceList.Assignments != null)
            {
                retVal.Assignments = priceList.Assignments.Select(x => x.ToWebModel(catalogs, etalonEpressionTree)).ToList();
            }
            return(retVal);
        }
Пример #2
0
        private PricingSearchResult <webModel.ProductPrice> SearchProductPricesImpl(PricesSearchCriteria criteria)
        {
            if (criteria == null)
            {
                criteria = new PricesSearchCriteria();
            }
            var result = _pricingSearchService.SearchPrices(criteria);
            var retVal = new PricingSearchResult <webModel.ProductPrice>
            {
                TotalCount = result.TotalCount,
                Results    = new List <webModel.ProductPrice>()
            };

            var products = _itemService.GetByIds(result.Results.Select(x => x.ProductId).Distinct().ToArray(), Domain.Catalog.Model.ItemResponseGroup.ItemInfo);

            foreach (var productPricesGroup in result.Results.GroupBy(x => x.ProductId))
            {
                var productPrice = new webModel.ProductPrice
                {
                    ProductId = productPricesGroup.Key,
                    Prices    = productPricesGroup.ToList()
                };
                var product = products.FirstOrDefault(x => x.Id == productPricesGroup.Key);
                if (product != null)
                {
                    productPrice.Product = product.ToWebModel(_blobUrlResolver);
                }
                retVal.Results.Add(productPrice);
            }
            return(retVal);
        }
Пример #3
0
		public static webModel.Pricelist ToWebModel(this coreModel.Pricelist priceList, coreCatalogModel.CatalogProduct[] products = null, coreCatalogModel.Catalog[] catalogs = null, ConditionExpressionTree etalonEpressionTree = null)
		{
			var retVal = new webModel.Pricelist();
			retVal.InjectFrom(priceList);
			retVal.Currency = priceList.Currency;
			if (priceList.Prices != null)
			{
				retVal.ProductPrices = new List<webModel.ProductPrice>();
				foreach(var group in priceList.Prices.GroupBy(x=>x.ProductId))
				{
					var productPrice = new webModel.ProductPrice(group.Key, group.Select(x=> x.ToWebModel()));
					
					retVal.ProductPrices.Add(productPrice);
					if (products != null)
					{
						var product = products.FirstOrDefault(x => x.Id == productPrice.ProductId);
						if(product != null)
						{
							productPrice.ProductName = product.Name;
						}
					}
				}
				
			}
			if(priceList.Assignments != null)
			{
				retVal.Assignments = priceList.Assignments.Select(x => x.ToWebModel(catalogs, etalonEpressionTree)).ToList();
			}
			return retVal;
		}
Пример #4
0
 public IHttpActionResult UpdateProductPrices(webModel.ProductPrice productPrice)
 {
     return(UpdateProductsPrices(new[] { productPrice }));
 }