Esempio n. 1
0
        /// <summary>
        /// Gets the model with the given alias url.
        /// </summary>
        /// <param name="url">The unique url</param>
        /// <param name="siteId">The optional site id</param>
        /// <returns>The model</returns>
        public async Task <Alias> GetByAliasUrlAsync(string url, Guid?siteId = null)
        {
            if (!siteId.HasValue)
            {
                var site = await _siteService.GetDefaultAsync().ConfigureAwait(false);

                if (site != null)
                {
                    siteId = site.Id;
                }
            }

            var   id    = _cache?.Get <Guid?>($"AliasId_{siteId}_{url}");
            Alias model = null;

            if (id.HasValue)
            {
                model = await GetByIdAsync(id.Value).ConfigureAwait(false);
            }
            else
            {
                model = await _repo.GetByAliasUrl(url, siteId.Value).ConfigureAwait(false);

                OnLoad(model);
            }
            return(model);
        }