Esempio n. 1
0
        public string BuildRouteApiUrl(string language, bool?hasRouteError)
        {
            string baseUrl = $"{_navigationManager.BaseUri}/data/routes";

            string relativeUrl = _navigationManager.ToBaseRelativePath(_navigationManager.Uri);

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

            IBlazorItem rootItem = _blazorItemsService.GetBlazorItemRootMock(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");
        }
Esempio n. 2
0
        public (bool IsCurrentUrl, string CurrentUrl)? UrlIsCurrent()
        {
            string relativeUrl = _navigationManager.ToBaseRelativePath(_navigationManager.Uri);

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

            IBlazorItem rootItem = _blazorItemsService.GetBlazorItemRootMock(_blazorStateMachine?.CurrentRoute?.ItemLanguage);

            return(_blazorStateMachine?.CurrentRoute != null && rootItem.GetItSelfAndDescendants().Any(item => item.Url == "/" + relativeUrl && item.Id == _blazorStateMachine.CurrentRoute.Id)
              ? (true, $"/{relativeUrl}")
              : (false, $"/{relativeUrl}"));
        }