public override IEnumerable <(CultureInfo, IDocument)> BuildIndexDocuments(IndexQueueItem item) { var page = _pageService.Get(item.SystemId); if (page == null) { yield break; } var cultureContentCache = new ConcurrentDictionary <CultureInfo, ISet <string> >(); var permissions = _searchPermissionService.GetPermissions(page); var blocks = page.Blocks.Items.SelectMany(x => x.Items).Select(y => _blockService.Get(((BlockItemLink)y).BlockSystemId)).ToList(); var isBrand = false; var isNews = false; if (_keyLookupService.TryGetId <PageFieldTemplate>(page.FieldTemplateSystemId, out var templateId)) { isBrand = PageTemplateNameConstants.Brand.Equals(templateId, StringComparison.OrdinalIgnoreCase); isNews = PageTemplateNameConstants.News.Equals(templateId, StringComparison.OrdinalIgnoreCase); } foreach (var channelLink in page.ChannelLinks) { var channel = _channelService.Get(channelLink.ChannelSystemId); if (channel is null) { // Orphaned category link exists, skip to create new index document. continue; } var cultureInfo = _languageService.Get(channel.WebsiteLanguageSystemId.GetValueOrDefault())?.CultureInfo; if (cultureInfo is null) { // Channel does not have a culture. continue; } var localization = page.Localizations[cultureInfo]; yield return(cultureInfo, new PageDocument { PageSystemId = page.SystemId, Content = cultureContentCache.GetOrAdd(cultureInfo, _ => _contentBuilderService.BuildContent <PageFieldTemplate, WebsiteArea>(page.FieldTemplateSystemId, cultureInfo, page.Fields)), PublishDateTime = page.PublishedAtUtc ?? DateTimeOffset.MinValue, Name = localization.Name, ChannelSystemId = channel.SystemId, WebsiteSystemId = page.WebsiteSystemId, ChannelStartDateTime = channelLink.StartDateTimeUtc ?? DateTimeOffset.MinValue, ChannelEndDateTime = channelLink.EndDateTimeUtc ?? DateTimeOffset.MaxValue, Permissions = permissions, Blocks = GetBlocks(blocks, cultureInfo, channel.SystemId), IsBrand = isBrand, IsNews = isNews, NewsDate = isNews ? page.Fields.GetValue <DateTimeOffset>(PageFieldNameConstants.NewsDate) : DateTimeOffset.MinValue, ParentPages = GetParenPages(page) }); } }
public override Task <CreateCartContextArgs> CreateAsync(CancellationToken cancellationToken = default) { var requestModel = _requestModelAccessor.RequestModel; if (requestModel != null) { return(Task.FromResult(new CreateCartContextArgs { ChannelSystemId = requestModel.ChannelModel.SystemId, MarketSystemId = requestModel.ChannelModel.Channel.MarketSystemId ?? Guid.Empty, CountryCode = requestModel.CountryModel.Country.Id, CurrencyCode = _keyLookupService.TryGetId <Currency>(requestModel.CountryModel.Country.CurrencySystemId, out var currencyCode) ? currencyCode : null, PersonSystemId = _securityContextService.GetIdentityUserSystemId() ?? null, OrganizationSystemId = _personStorage.CurrentSelectedOrganization?.SystemId ?? null, ClientIp = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress?.ToString(), ClientBrowser = _httpContextAccessor.HttpContext?.Request.Headers["User-Agent"].ToString(), ShowPricesWithVat = requestModel.ChannelModel.Channel.ShowPricesWithVat }));