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 }; })); }
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 })); }
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); }