예제 #1
0
        public IList <IPriceValue> GetDiscountPriceList(IEnumerable <CatalogKey> catalogKeys, MarketId marketId, Currency currency)
        {
            var market = _marketService.GetMarket(marketId);

            if (market == null)
            {
                throw new ArgumentException(string.Format("market '{0}' does not exist", marketId));
            }

            var prices = catalogKeys.Select(x => PriceCalculationService.GetSalePrice(x.CatalogEntryCode, marketId, currency)).Where(x => x != null);

            return(GetDiscountPrices(prices.ToList(), market, currency));
        }
예제 #2
0
        private ProductTileViewModel CreateProductViewModelForEntry(EntryContentBase entry)
        {
            var   market        = _currentMarketService.GetCurrentMarket();
            var   currency      = _currencyService.GetCurrentCurrency();
            var   originalPrice = PriceCalculationService.GetSalePrice(entry.Code, market.MarketId, market.DefaultCurrency);
            Money?discountedPrice;

            if (originalPrice?.UnitPrice == null || originalPrice.UnitPrice.Amount == 0)
            {
                originalPrice = new PriceValue()
                {
                    UnitPrice = new Money(0, market.DefaultCurrency)
                };
                discountedPrice = null;
            }
            else
            {
                discountedPrice = GetDiscountPrice(entry, market, currency, originalPrice.UnitPrice);
            }

            var image        = entry.GetAssets <IContentImage>(_contentLoader, _urlResolver).FirstOrDefault() ?? "";
            var currentStore = _storeService.GetCurrentStoreViewModel();

            return(new ProductTileViewModel
            {
                Code = entry.Code,
                DisplayName = entry.DisplayName,
                PlacedPrice = originalPrice.UnitPrice,
                DiscountedPrice = discountedPrice,
                ImageUrl = image,
                Url = entry.GetUrl(),
                IsAvailable = originalPrice.UnitPrice != null && originalPrice.UnitPrice.Amount > 0,
                Stores = new StoreViewModel
                {
                    Stores = _storeService.GetEntryStoresViewModels(entry.Code),
                    SelectedStore = currentStore != null ? currentStore.Code : "",
                    SelectedStoreName = currentStore != null ? currentStore.Name : ""
                }
            });
        }