public async Task <string> ResolveLinkUrlAsync(IContentLink link) { var urlHelper = GetHelper(_urlHelperFactory, _actionContextAccessor); switch (link.ContentTypeCodename) { case AboutUs.Codename: case FactAboutUs.Codename: return(await TranslateLink("Index", "About")); case Article.Codename: return(await TranslateLink("Show", "Articles", new { urlSlug = link.UrlSlug })); case Brewer.Codename: case Coffee.Codename: return(await TranslateLink("Detail", "Product", new { urlSlug = link.UrlSlug })); case Cafe.Codename: return(await TranslateLink("Index", "Cafes")); case Home.Codename: return(await TranslateLink("Index", "Home")); default: return(urlHelper.Action("NotFound", "Errors")); } }
private RelatedLinkDto ConvertToLinkDto(int siteId, IContentLink link) { ISite site = this._siteRep.GetSiteById(link.RelatedSiteId); IBaseContent content = this.GetContent(site.GetAggregaterootId(), ContentTypeIndent.Archive.ToString().ToLower(), link.RelatedContentId); String thumbnail = null; IArchive archive = content as IArchive; if (archive != null) { thumbnail = archive.Get().Thumbnail; } return(new RelatedLinkDto { Id = link.Id, Enabled = link.Enabled, ContentId = link.ContentId, ContentType = link.ContentType, RelatedSiteId = link.RelatedSiteId, RelatedSiteName = site.Get().Name, RelatedContentId = link.RelatedContentId, RelatedIndent = link.RelatedIndent, Title = archive.Get().Title, Url = site.FullDomain + archive.Get().Path, Thumbnail = thumbnail, IndentName = ContentUtil.GetRelatedIndentName(link.RelatedIndent).Name, }); }
public Task <string> ResolveLinkUrlAsync(IContentLink link) { // Resolves URLs to content items based on the 'accessory' content type return(Task.FromResult(link.ContentTypeCodename switch { "post" => $"/Post/Details/{link.UrlSlug}", _ => "/404", }));
public async Task <string> ResolveLinkUrlAsync(IContentLink link) { // Resolves URLs to content items based on the 'accessory' content type return(await Task.FromResult(link.ContentTypeCodename switch { "article" => $"/Articles/Detail/{link.UrlSlug}", "coffee" => $"/Coffees/Detail/{link.UrlSlug}", _ => "/404", }));
public Task <string> ResolveLinkUrlAsync(IContentLink link) { // Resolves URLs to content items based on the Article content type if (link.ContentTypeCodename == "article") { return(Task.FromResult($"/articles/{link.UrlSlug}")); } // TODO: Add the rest of the resolver logic }
public Task <string> ResolveLinkUrlAsync(IContentLink link) { var result = link.ContentTypeCodename switch { "post" => $"{link.UrlSlug}", _ => "/404", }; return(Task.FromResult(result)); }
public Task <string> ResolveLinkUrlAsync(IContentLink link) { // Resolves URLs to content items based on the 'accessory' content type return(Task.FromResult(link.ContentTypeCodename switch { Article.Codename => $"/post/{link.UrlSlug}", Page.Codename => $"/pages/{link.UrlSlug}", Category.Codename => $"/category/{link.UrlSlug}", Tag.Codename => $"/tag/{link.UrlSlug}", _ => "/404", }));
public bool Equal(IValueObject that) { IContentLink link = that as IContentLink; if (link != null) { if (link.ContentId == this.ContentId && link.RelatedContentId == this.RelatedContentId ) { return(true); } } return(false); }
public void RemoveRelatedLink(int id) { if (this._delLinkIds == null) { this._delLinkIds = new List <int>(); } for (int i = 0; i < this._links.Count; i++) { if (this._links[i].Id == id) { IContentLink link = this._links[i]; this._links.Remove(link); this._delLinkIds.Add(link.Id); link = null; } } }
public int SaveRelatedLink(int siteId, RelatedLinkDto linkDto) { IBaseContent content = this.GetContent(siteId, linkDto.ContentType, linkDto.ContentId); if (linkDto.Id > 0) { IContentLink link = content.LinkManager.GetLinkById(linkDto.Id); link.RelatedIndent = linkDto.RelatedIndent; link.RelatedContentId = linkDto.RelatedContentId; link.Enabled = linkDto.Enabled; link.RelatedSiteId = linkDto.RelatedSiteId; } else { content.LinkManager.Add(linkDto.Id, linkDto.RelatedSiteId, linkDto.RelatedIndent, linkDto.RelatedContentId, linkDto.Enabled); } content.LinkManager.SaveRelatedLinks(); return(linkDto.Id); }
public void Add(int id, int relatedSiteId, int relatedIndent, int relatedId, bool enabled) { IContentLink link = null; if (this._contentType == ContentTypeIndent.Archive.ToString().ToLower()) { link = new LinkOfArchive(id, this._contentType, this._contentId, relatedSiteId, relatedIndent, relatedId, enabled); } if (link != null) { foreach (IContentLink link2 in this._links) { if (link2.Equal(link)) { throw new Exception("已存在重名的链接!"); } } this._links.Add(link); } }
/// <summary> /// Adds a broken link out. /// </summary> /// <param name="contentLink">The broken link</param> /// <exception cref="ArgumentException">A broken link to this element already exists</exception> public void AddBrokenLinkOut(IContentLink contentLink) { AddLink(ref missingChildren, new AssetLink(contentLink.Element, contentLink.Type)); }
public Task <string> ResolveLinkUrlAsync(IContentLink link) { return(Task.FromResult(GetLinkUrl(link))); }
public Task <string> ResolveLinkUrlAsync(IContentLink link) => Task.FromResult <string>(null);
/// <summary> /// Resolves the link URL. /// </summary> /// <param name="link">The link.</param> /// <returns>A relative URL to the page where the content is displayed</returns> public Task <string> ResolveLinkUrlAsync(IContentLink link) { return(Task.FromResult($"/{link.UrlSlug}")); }