public HttpResponseMessage GetRedirectsForContent(Guid contentKey)
        {
            if (this.IsUrlTrackingDisabled())
            {
                return(new HttpResponseMessage(HttpStatusCode.Conflict));
            }

            var redirects = _mapper.MapEnumerable <IRedirectUrl, ContentRedirectUrl>(_redirectUrlService.GetContentRedirectUrls(contentKey).ToArray());

            return(this.Request.CreateResponse(HttpStatusCode.OK, redirects));
        }
        public string[] GetRedirects(Guid contentKey, string culture)
        {
            var redirects = _redirectUrlService.GetContentRedirectUrls(contentKey)
                            ?.Where(redirect => string.IsNullOrWhiteSpace(redirect.Culture) ||
                                    redirect.Culture.ToLowerInvariant().Equals(culture.ToLowerInvariant()));

            if (redirects == null)
            {
                return(new string[0]);
            }

            return(redirects
                   .Select(redirect => _umbracoUrlService.GetUrlFromIdUrl(redirect.Url, redirect.Culture))
                   .ToArray());
        }
Esempio n. 3
0
        public HttpResponseMessage GetRedirectsForContent(Guid contentKey, string culture = "")
        {
            if (this.IsUrlTrackingDisabled())
            {
                return(new HttpResponseMessage(HttpStatusCode.Conflict));
            }

            var redirects = _mapper.MapEnumerable <IRedirectUrl, ContentRedirectUrl>(_redirectUrlService.GetContentRedirectUrls(contentKey).ToList());

            if (!string.IsNullOrEmpty(culture))
            {
                redirects = redirects.Where(x => x.Culture.InvariantEquals(culture)).ToList();
            }

            return(this.Request.CreateResponse(HttpStatusCode.OK, redirects));
        }
Esempio n. 4
0
        public RedirectUrlSearchResult RedirectUrlsForContentItem(string contentUdi)
        {
            var redirectsResult = new RedirectUrlSearchResult();

            if (UdiParser.TryParse(contentUdi, out GuidUdi guidIdi))
            {
                var redirects = _redirectUrlService.GetContentRedirectUrls(guidIdi.Guid);
                var mapped    = _umbracoMapper.MapEnumerable <IRedirectUrl, ContentRedirectUrl>(redirects);
                redirectsResult.SearchResults = mapped;
                //not doing paging 'yet'
                redirectsResult.TotalCount  = mapped.Count;
                redirectsResult.CurrentPage = 1;
                redirectsResult.PageCount   = 1;
            }
            return(redirectsResult);
        }