public async Task <SiteContext> ResolveSite( string hostName, string pathStartingSegment, CancellationToken cancellationToken = default(CancellationToken) ) { ISiteSettings site = null; if (_multiTenantOptions.Mode == MultiTenantMode.FolderName) { if (string.IsNullOrWhiteSpace(pathStartingSegment)) { pathStartingSegment = "root"; } site = await _siteQueries.FetchByFolderName(pathStartingSegment, cancellationToken); } else { site = await _siteQueries.Fetch(hostName, cancellationToken); } if (site != null) { _dataProtector.UnProtect(site); return(new SiteContext(site)); } return(null); }
private async Task<TenantContext<SiteContext>> ResolveByFolderAsync(HttpContext context) { var siteFolderName = await GetContextIdentifier(context); TenantContext<SiteContext> tenantContext = null; CancellationToken cancellationToken = context?.RequestAborted ?? CancellationToken.None; var site = await siteRepo.FetchByFolderName(siteFolderName, cancellationToken); if (site != null) { dataProtector.UnProtect(site); var siteContext = new SiteContext(site); tenantContext = new TenantContext<SiteContext>(siteContext); } return tenantContext; }
/// <summary> /// returns true if the folder is not in use or is in use only on the passed in ISiteSettings /// </summary> /// <param name=""></param> /// <param name="requestedFolderName"></param> /// <returns></returns> public async Task <bool> FolderNameIsAvailable(Guid requestingSiteId, string requestedFolderName) { var matchingSite = await _queries.FetchByFolderName(requestedFolderName, CancellationToken).ConfigureAwait(false); if (matchingSite == null) { return(true); } if (matchingSite.SiteFolderName != requestedFolderName) { return(true); } if (matchingSite.Id == requestingSiteId) { return(true); } return(false); }
/// <summary> /// returns true if the folder is not in use or is in use only on the passed in ISiteSettings /// </summary> /// <param name=""></param> /// <param name="requestedFolderName"></param> /// <returns></returns> public async Task <bool> FolderNameIsAvailable(ISiteSettings requestingSite, string requestedFolderName) { var matchingSite = await queries.FetchByFolderName(requestedFolderName, CancellationToken); if (matchingSite == null) { return(true); } if (matchingSite.SiteFolderName != requestedFolderName) { return(true); } if (matchingSite.Id == requestingSite.Id) { return(true); } return(false); }
private async Task<TenantContext<SiteSettings>> ResolveByFolderAsync(HttpContext context) { var siteFolderName = context.Request.Path.StartingSegment(); if (siteFolderName.Length == 0) { siteFolderName = "root"; } TenantContext<SiteSettings> tenantContext = null; CancellationToken cancellationToken = context?.RequestAborted ?? CancellationToken.None; var site = await siteRepo.FetchByFolderName(siteFolderName, cancellationToken); if (site != null) { dataProtector.UnProtect(site); tenantContext = new TenantContext<SiteSettings>((SiteSettings)site); } return tenantContext; }