Пример #1
0
        public string BuildRouteApiUrl(string language, bool?hasRouteError)
        {
            string baseUrl = $"{_uriHelper.GetBaseUri()}/data/routes";

            string relativeUrl = $"{_uriHelper.ToBaseRelativePath(_uriHelper.GetBaseUri(), _uriHelper.GetAbsoluteUri())}";

            //Incorrect url
            if (hasRouteError.HasValue && hasRouteError.Value)
            {
                return($"{baseUrl}/error/{language}.json");
            }

            ISitecoreItem rootItem = _sitecoreItemService.GetSitecoreItemRootMock(language);

            if (rootItem.GetItSelfAndDescendants().Any(item => item.Url == "/" + relativeUrl) || relativeUrl == "")
            {
                if (relativeUrl.Length <= language.Length)
                {
                    return($"{baseUrl}/{language}.json");
                }

                return($"{baseUrl}{relativeUrl.Substring(language.Length)}/{language}.json");
            }


            return($"{baseUrl}/error/{language}.json");
        }
Пример #2
0
        public (bool IsCurrentUrl, string CurrentUrl) UrlIsCurrent()
        {
            string relativeUrl = _uriHelper.ToBaseRelativePath(_uriHelper.GetBaseUri(), _uriHelper.GetAbsoluteUri());

            if (string.IsNullOrWhiteSpace(_blazorStateMachine.CurrentRoute?.ItemLanguage))
            {
                return(false, $"/{relativeUrl}");
            }

            ISitecoreItem rootItem = _sitecoreItemService.GetSitecoreItemRootMock(_blazorStateMachine.CurrentRoute.ItemLanguage);

            return(_blazorStateMachine.CurrentRoute != null && rootItem.GetItSelfAndDescendants().Any(item => item.Url == "/" + relativeUrl && item.Id == _blazorStateMachine.CurrentRoute.Id)
              ? (true, $"/{relativeUrl}")
              : (false, $"/{relativeUrl}"));
        }
Пример #3
0
        public string BuildRouteApiUrl(string language)
        {
            string baseUrl = $"{_uriHelper.GetBaseUri()}/data/routes";

            string relativeUrl = $"{_uriHelper.ToBaseRelativePath(_uriHelper.GetBaseUri(), _uriHelper.GetAbsoluteUri())}";

            //Language is wrong
            if (!IsValidLanguage(language))
            {
                language = "en"; //TODO move to languageservice GetFallbackLanguage;
                return($"{baseUrl}/error/{language}.json");
            }

            ISitecoreItem rootItem = _sitecoreItemService.GetSitecoreItemRootMock(language);

            if (rootItem.GetItSelfAndDescendants().Any(item => item.Url == "/" + relativeUrl) || relativeUrl == "")
            {
                return($"{baseUrl}{relativeUrl.Substring(language.Length)}/{language}.json");
            }

            return($"{baseUrl}/error/{language}.json");
        }