public static IEnumerable <VariationContent> GetAllVariants(this ContentReference contentLink) { return(contentLink.GetAllVariants <VariationContent>()); }
public Importer(ContentReference importRoot) { _importRoot = importRoot; _importEvents = new ImportEvents(); }
public static IEnumerable <Price> GetPrices(this ContentReference entryContents, MarketId marketId, PriceFilter priceFilter) => new[] { entryContents }.GetPrices(marketId, priceFilter);
public static string GetCode(this ContentReference contentLink) => ReferenceConverter.Value.GetCode(contentLink);
public static RouteValueDictionary GetPageRoute(this RequestContext requestContext, ContentReference contentLink) { var values = new RouteValueDictionary(); values[RoutingConstants.NodeKey] = contentLink; values[RoutingConstants.LanguageKey] = ContentLanguage.PreferredCulture.Name; return(values); }
public static CatalogKey GetCatalogKey(this ContentReference contentReference) => new CatalogKey(ReferenceConverter.Value.GetCode(contentReference));
private CacheEvictionPolicy GetEvictionPolicy(ContentReference contentLink) { return(new CacheEvictionPolicy(new[] { contentCacheKeyCreator.CreateCommonCacheKey(contentLink) })); }
public static ProductTileViewModel GetProductTileViewModel(this EntryContentBase entry, IMarket market, Currency currency, bool isFeaturedProduct = false) { var entryRecommendations = entry as IProductRecommendations; var product = entry; var entryUrl = ""; var firstCode = ""; var type = typeof(GenericProduct); if (entry is GenericProduct) { var variants = GetProductVariants(entry); if (variants != null && variants.Any()) { firstCode = variants.First().Code; } entryUrl = UrlResolver.Value.GetUrl(entry.ContentLink); } if (entry is GenericBundle) { type = typeof(GenericBundle); firstCode = product.Code; entryUrl = UrlResolver.Value.GetUrl(product.ContentLink); } if (entry is GenericPackage) { type = typeof(GenericPackage); firstCode = product.Code; entryUrl = UrlResolver.Value.GetUrl(product.ContentLink); } if (entry is GenericVariant) { var variantEntry = entry as GenericVariant; type = typeof(GenericVariant); firstCode = entry.Code; var parentLink = entry.GetParentProducts().FirstOrDefault(); if (ContentReference.IsNullOrEmpty(parentLink)) { product = ContentLoader.Value.Get <EntryContentBase>(variantEntry.ContentLink); entryUrl = UrlResolver.Value.GetUrl(variantEntry.ContentLink); } else { product = ContentLoader.Value.Get <EntryContentBase>(parentLink) as GenericProduct; entryUrl = UrlResolver.Value.GetUrl(product.ContentLink) + "?variationCode=" + variantEntry.Code; } } IPriceValue price = PriceCalculationService.GetSalePrice(firstCode, market.MarketId, currency); if (price == null) { price = GetEmptyPrice(entry, market, currency); } IPriceValue discountPrice = price; if (price.UnitPrice.Amount > 0 && !string.IsNullOrEmpty(firstCode)) { discountPrice = PromotionService.Value.GetDiscountPrice(new CatalogKey(firstCode), market.MarketId, currency); } bool isAvailable = price.UnitPrice.Amount > 0; return(new ProductTileViewModel { ProductId = product.ContentLink.ID, Brand = entry.Property.Keys.Contains("Brand") ? entry.Property["Brand"]?.Value?.ToString() ?? "" : "", Code = product.Code, DisplayName = entry.DisplayName, Description = entry.Property.Keys.Contains("Description") ? entry.Property["Description"]?.Value != null ? ((XhtmlString)entry.Property["Description"].Value).ToHtmlString() : "" : "", LongDescription = ShortenLongDescription(entry.Property.Keys.Contains("LongDescription") ? entry.Property["LongDescription"]?.Value != null ? ((XhtmlString)entry.Property["LongDescription"].Value).ToHtmlString() : "" : ""), PlacedPrice = price.UnitPrice, DiscountedPrice = discountPrice.UnitPrice, FirstVariationCode = firstCode, ImageUrl = AssetUrlResolver.Value.GetAssetUrl <IContentImage>(entry), VideoAssetUrl = AssetUrlResolver.Value.GetAssetUrl <IContentVideo>(entry), Url = entryUrl, IsAvailable = isAvailable, OnSale = entry.Property.Keys.Contains("OnSale") && ((bool?)entry.Property["OnSale"]?.Value ?? false), NewArrival = entry.Property.Keys.Contains("NewArrival") && ((bool?)entry.Property["NewArrival"]?.Value ?? false), ShowRecommendations = entryRecommendations != null ? entryRecommendations.ShowRecommendations : true, EntryType = type, ProductStatus = entry.Property.Keys.Contains("ProductStatus") ? entry.Property["ProductStatus"]?.Value?.ToString() ?? "Active" : "Active", Created = entry.Created, IsFeaturedProduct = isFeaturedProduct }); }
public static string GetInternalUrl(this ContentReference reference, string locale) => GetUrl(reference, locale, false);
public static string GetExternalUrl(this ContentReference reference, string locale) => GetUrl(reference, locale, true);
/// <summary> /// Handles the <see cref="E:PublishedContent" /> event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="contentEventArgs">The <see cref="ContentEventArgs" /> instance containing the event data.</param> public void OnPublishedContent(object sender, ContentEventArgs contentEventArgs) { if (contentEventArgs == null) { return; } // Check if the content that is published is indeed a block. BlockData blockData = contentEventArgs.Content as BlockData; // If it's not, don't do anything. if (blockData == null) { return; } // Get the references to this block List <ContentReference> referencingContentLinks = this.ContentSoftLinkRepository.Service.Load(contentEventArgs.ContentLink, true) .Where( link => (link.SoftLinkType == ReferenceType.PageLinkReference) && !ContentReference.IsNullOrEmpty(link.OwnerContentLink)) .Select(link => link.OwnerContentLink) .ToList(); // Loop through each reference foreach (ContentReference referencingContentLink in referencingContentLinks) { PageData parent; this.ContentRepository.Service.TryGet(referencingContentLink, out parent); // If it is not pagedata, do nothing if (parent == null) { Logger.Information("[Blocksearch] Referencing content is not a page. Skipping update."); continue; } // Check if the containing page is published. if (!parent.CheckPublishedStatus(PagePublishedStatus.Published)) { Logger.Information("[Blocksearch] page named '{0}' is not published. Skipping update.", parent.Name); continue; } // Republish the containing page. try { this.ContentRepository.Service.Save( parent.CreateWritableClone(), SaveAction.Publish | SaveAction.ForceCurrentVersion, AccessLevel.NoAccess); Logger.Information("[Blocksearch] Updated containing page named '{0}'.", parent.Name); } catch (AccessDeniedException accessDeniedException) { Logger.Error( string.Format( CultureInfo.InvariantCulture, "[Blocksearch] Not enough accessrights to republish containing pagetype named '{0}'.", parent.Name), accessDeniedException); } } }
protected void CreateEvent(string eventString, ContentReference parent, string language) { EventPageBase NewEvent = EPiServer.DataFactory.Instance.GetDefault <EventPageBase>(parent, new LanguageSelector(language)); string ParticipantsString = ""; string DetailsBody = ""; string Status = ""; foreach (string EventData in DelimitContent(eventString, "[EVENTFIELDDELIMITER]")) { string[] EventDataValues = DelimitContent(EventData, "[DATAVALUEDELIMITER]"); if (EventDataValues.Length > 1) { string dataKey = EventDataValues[0]; string dataValue = EventDataValues[1]; Status += "- " + dataKey + ": " + dataValue + "<br>"; if (!string.IsNullOrEmpty(dataKey) && !string.IsNullOrEmpty(dataValue)) { switch (dataKey) { case "Participants": ParticipantsString = dataValue; //StatusLiteral.Text += DelimitContent(EventDataValues[1], "[PARTICIPANTDELIMITER")[0]; break; case "EventName": NewEvent.Name = dataValue; break; case "EventStart": NewEvent.EventDetails.EventStart = GetDateSafe(dataValue); break; case "EventEnd": NewEvent.EventDetails.EventEnd = GetDateSafe(dataValue); break; case "RegistrationOpen": NewEvent.EventDetails.RegistrationOpen = GetDateSafe(dataValue); break; case "RegistrationClose": NewEvent.EventDetails.RegistrationClose = GetDateSafe(dataValue); break; case "AutoConfirmThreshold": NewEvent.EventDetails.NumberOfSeats = GetIntSafe(dataValue); break; case "IntroBody": NewEvent.IntroBody = new XhtmlString(dataValue); break; case "DetailsBody": DetailsBody = dataValue; break; case "Price": NewEvent.EventDetails.Price = GetIntSafe(dataValue); break; } } } } NewEvent.RemoveFieldsFromView = ""; NewEvent.RegistrationForm = XFormInput.XForm; EPiServer.DataFactory.Instance.Save(NewEvent, EPiServer.DataAccess.SaveAction.Publish); StatusLiteral.Text += "<h2>" + NewEvent.Name + "</h2>"; CreateParticipants(ParticipantsString, NewEvent.ContentLink); }
} // somewhat temporary private IEnumerable <ContentReference> GetAssociatedReferences() { // For test string assocType = String.Empty; string assocGroup = String.Empty; assocGroup = "CrossSell"; // ...for now, need to find an appropriate "prop" ContentReference theOne = c_helper.Service.ContentLink; List <ContentReference> refs = new List <ContentReference>(); var c = loader.Service.Get <VariationContent>(theOne); // have the extensions-NS... "up there" IEnumerable <Association> assoc = c.GetAssociations(); StringBuilder strB = new StringBuilder(); /* AssociationType: * Cool NiceToHave * Default NULL * OPTIONAL Optional * REQUIRED Required * NULL NULL*/ /* CatalogAssociation: * 2 2 CrossSell NULL 0 * 5 2 UpSell For making a customer happier 0 * NULL NULL NULL NULL NULL*/ /* CatalogEntryAssociation: * 2 6 100 Cool * 5 6 0 Cool * NULL NULL NULL NULL*/ if (assoc.Count() >= 1) { foreach (Association item in assoc) { if (item.Group.Name == assocGroup) { refs.Add(item.Target); Type = item.Type.Description; Group = item.Group.Name; } } // need some additional stuff //Association a = assoc.FirstOrDefault(); // get the only one .. so far for test //strB.Append("Group-Name: " + a.Group.Name); //strB.Append(" "); //strB.Append("Type-Descr: " + a.Type.Description); //// there is more to get out return(refs); } else { //strB.Append("Nothing"); Type = "Nothing"; refs.Add(ContentReference.SelfReference); return(refs); } }
public override bool CanCache(ContentReference fileRef) { return(fileRef is IGoogleMapsRequest && base.CanCache(fileRef)); }
protected override IList <GetChildrenReferenceResult> LoadChildrenReferencesAndTypes(ContentReference contentLink, string languageID, out bool languageSpecific) { // If retrieving children for the entry point, we retrieve pages from the clone root contentLink = contentLink.CompareToIgnoreWorkID(_entryRoot) ? _cloneRoot : contentLink; var children = _contentStore.LoadChildrenReferencesAndTypes(contentLink.ID, languageID, out FilterSortOrder sortOrder); languageSpecific = sortOrder == FilterSortOrder.Alphabetical; foreach (var contentReference in children.Where(contentReference => !contentReference.ContentLink.CompareToIgnoreWorkID(_entryRoot))) { contentReference.ContentLink.ProviderName = ProviderKey; } return(FilterByCategory <GetChildrenReferenceResult>(children)); }