Exemplo n.º 1
0
        private IEnumerable <ProductViewModel> CreateProductViewModels(IContentResult <BaseProduct> searchResult)
        {
            var market   = _currentMarket.GetCurrentMarket();
            var currency = _currencyService.GetCurrentCurrency();

            return(searchResult.Select(product =>
            {
                var originalPrice = product.OriginalPrices.FirstOrDefault(
                    p => p.MarketId == market.MarketId && p.UnitPrice.Currency == currency);
                var listingPrice = product.ListingPrices.FirstOrDefault(
                    p => p.MarketId == market.MarketId && p.UnitPrice.Currency == currency);
                return new ProductViewModel
                {
                    Brand = product.Brand,
                    Code = product.Code,
                    DisplayName = product.DisplayName,
                    PlacedPrice = originalPrice?.UnitPrice ?? new Money(0, currency),
                    DiscountedPrice = listingPrice?.UnitPrice ?? new Money(0, currency),
                    ImageUrl = _assetUrlResolver.GetAssetUrl <IContentImage>(product),
                    Url = _urlResolver.GetUrl(product.ContentLink),
                    IsAvailable = originalPrice != null && originalPrice.UnitPrice.Amount > 0,
                    MarketFilter = product.MarketFilter?.ToString() ?? string.Empty
                };
            }));
        }
Exemplo n.º 2
0
 private IEnumerable <ProductViewModel> CreateProductViewModels(IContentResult <FashionProduct> searchResults)
 {
     return(searchResults.Select(product => new ProductViewModel
     {
         Brand = product.Brand,
         Code = product.Code,
         DisplayName = product.DisplayName,
         ImageUrl = product.DefaultImageUrl(),
         PlacedPrice = product.DefaultPrice(),
         DiscountedPrice = product.DiscountPrice(),
         Url = _urlResolver.GetUrl(product.ContentLink),
         IsAvailable = true
     }));
 }
Exemplo n.º 3
0
        public IEnumerable <ProductTileViewModel> CreateProductViewModels(IContentResult <EntryContentBase> searchResult, IContent content, string searchQuery)
        {
            List <ProductTileViewModel> productViewModels = null;
            var market   = _currentMarket.GetCurrentMarket();
            var currency = _currencyService.GetCurrentCurrency();

            if (searchResult == null)
            {
                throw new ArgumentNullException(nameof(searchResult));
            }

            productViewModels = searchResult.Select(document => document.GetProductTileViewModel(market, currency)).ToList();
            ApplyBoostedProperties(ref productViewModels, searchResult, content, searchQuery);
            return(productViewModels);
        }