public async Task <IProjectSettings> GetCurrentProjectSettings(CancellationToken cancellationToken)
        {
            IProjectSettings settings;

            if (_cultureHelper.UseCultureRoutesAndProjects() && !_cultureHelper.IsDefaultCulture())
            {
                var settingsKey = _currentSite.Id.ToString() + "~" + _cultureHelper.CurrentUICultureName();
                settings = await _projectQueries.GetProjectSettings(settingsKey, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                settings = await _projectQueries.GetProjectSettings(_currentSite.Id.ToString(), cancellationToken).ConfigureAwait(false);
            }

            //ensure existence of settings
            if (settings == null)
            {
                settings    = new ProjectSettings();
                settings.Id = _currentSite.Id.ToString();
                if (!_uiOptions.ShowBlogMenuOptions)
                {
                    settings.AddBlogToPagesTree        = false;
                    settings.BlogMenuLinksToNewestPost = false;
                }

                if (_cultureHelper.UseCultureRoutesAndProjects() && !_cultureHelper.IsDefaultCulture())
                {
                    settings.Id = settings.Id + "~" + _cultureHelper.CurrentUICultureName();
                }

                if (!_uiOptions.ShowBlogMenuOptions)
                {
                    // ShowBlogMenuOptions is true only when "option a" in the vsix template
                    // which implies that the default page slug should be forced to 'home'.
                    // Otherwise...
                    settings.DefaultPageSlug = "page1";
                }

                await _projectCommands.Create(settings.Id, settings, cancellationToken).ConfigureAwait(false);
            }

            if (string.IsNullOrEmpty(settings.RecaptchaPublicKey))
            {
                settings.RecaptchaPublicKey  = _currentSite.RecaptchaPublicKey;
                settings.RecaptchaPrivateKey = _currentSite.RecaptchaPrivateKey;
            }

            if (!_uiOptions.ShowBlogMenuOptions)
            {
                settings.AddBlogToPagesTree = false;
            }


            settings.TimeZoneId = _currentSite.TimeZoneId;



            return(settings);
        }
        public async Task <IProjectSettings> GetCurrentProjectSettings(CancellationToken cancellationToken)
        {
            IProjectSettings settings;

            if (_cultureHelper.UseCultureRoutesAndProjects() && !_cultureHelper.IsDefaultCulture())
            {
                var settingsKey = _currentSite.Id.ToString() + "~" + _cultureHelper.CurrentUICultureName();
                settings = await _projectQueries.GetProjectSettings(settingsKey, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                settings = await _projectQueries.GetProjectSettings(_currentSite.Id.ToString(), cancellationToken).ConfigureAwait(false);
            }

            //ensure existence of settings
            if (settings == null)
            {
                settings    = new ProjectSettings();
                settings.Id = _currentSite.Id.ToString();
                if (!_uiOptions.ShowBlogMenuOptions)
                {
                    settings.AddBlogToPagesTree        = false;
                    settings.BlogMenuLinksToNewestPost = false;
                }

                if (_cultureHelper.UseCultureRoutesAndProjects() && !_cultureHelper.IsDefaultCulture())
                {
                    settings.Id = settings.Id + "~" + _cultureHelper.CurrentUICultureName();
                }

                await _projectCommands.Create(settings.Id, settings, cancellationToken).ConfigureAwait(false);
            }

            if (string.IsNullOrEmpty(settings.RecaptchaPublicKey))
            {
                settings.RecaptchaPublicKey  = _currentSite.RecaptchaPublicKey;
                settings.RecaptchaPrivateKey = _currentSite.RecaptchaPrivateKey;
            }

            if (!_uiOptions.ShowBlogMenuOptions)
            {
                settings.AddBlogToPagesTree = false;
            }


            settings.TimeZoneId = _currentSite.TimeZoneId;



            return(settings);
        }
Пример #3
0
        public async Task <IProjectSettings> GetCurrentProjectSettings(CancellationToken cancellationToken)
        {
            var settings = await projectQueries.GetProjectSettings(currentSite.Id.ToString(), cancellationToken).ConfigureAwait(false);

            //ensure existence of settings
            if (settings == null)
            {
                settings    = new ProjectSettings();
                settings.Id = currentSite.Id.ToString();

                await projectCommands.Create(settings.Id, settings, cancellationToken).ConfigureAwait(false);
            }

            if (string.IsNullOrEmpty(settings.RecaptchaPublicKey))
            {
                settings.RecaptchaPublicKey  = currentSite.RecaptchaPublicKey;
                settings.RecaptchaPrivateKey = currentSite.RecaptchaPrivateKey;
            }

            settings.EmailFromAddress = currentSite.DefaultEmailFromAddress;
            settings.SmtpPassword     = currentSite.SmtpPassword;
            settings.SmtpPort         = currentSite.SmtpPort;
            settings.SmtpRequiresAuth = currentSite.SmtpRequiresAuth;
            settings.SmtpServer       = currentSite.SmtpServer;
            settings.SmtpUser         = currentSite.SmtpUser;
            settings.SmtpUseSsl       = currentSite.SmtpUseSsl;
            settings.TimeZoneId       = currentSite.TimeZoneId;

            return(settings);
        }
        //private IProjectCommands projectCommands;

        public async Task <IProjectSettings> GetCurrentProjectSettings(CancellationToken cancellationToken)
        {
            var settings = await projectQueries.GetProjectSettings(currentTenant.ContentProjectId, cancellationToken).ConfigureAwait(false);

            if ((settings != null) && (string.IsNullOrEmpty(settings.RecaptchaPublicKey)))
            {
                settings.RecaptchaPublicKey  = currentTenant.RecaptchaPublicKey;
                settings.RecaptchaPrivateKey = currentTenant.RecaptchaPrivateKey;
            }

            return(settings);
        }
        public async Task <IProjectSettings> GetCurrentProjectSettings(CancellationToken cancellationToken)
        {
            var settings = await projectQueries.GetProjectSettings(currentSite.Id.ToString(), cancellationToken).ConfigureAwait(false);

            //ensure existence of settings
            if (settings == null)
            {
                settings    = new ProjectSettings();
                settings.Id = currentSite.Id.ToString();
                if (!string.IsNullOrEmpty(currentSite.AliasId))
                {
                    settings.LocalMediaVirtualPath = "/" + currentSite.AliasId + "/media/images/";
                    // need to create the folder path below wwwroot
                    var segments = new string[3] {
                        currentSite.AliasId, "media", "images"
                    };
                    folderHelper.EnsureMediaFolderExists(segments);
                }

                await projectCommands.Create(settings.Id, settings, cancellationToken).ConfigureAwait(false);
            }

            if (string.IsNullOrEmpty(settings.RecaptchaPublicKey))
            {
                settings.RecaptchaPublicKey  = currentSite.RecaptchaPublicKey;
                settings.RecaptchaPrivateKey = currentSite.RecaptchaPrivateKey;
            }

            settings.EmailFromAddress = currentSite.DefaultEmailFromAddress;
            settings.SmtpPassword     = currentSite.SmtpPassword;
            settings.SmtpPort         = currentSite.SmtpPort;
            settings.SmtpRequiresAuth = currentSite.SmtpRequiresAuth;
            settings.SmtpServer       = currentSite.SmtpServer;
            settings.SmtpUser         = currentSite.SmtpUser;
            settings.SmtpUseSsl       = currentSite.SmtpUseSsl;
            settings.TimeZoneId       = currentSite.TimeZoneId;

            return(settings);
        }
Пример #6
0
 public async Task <IProjectSettings> GetProjectSettings(string projectId)
 {
     return(await _projectQueries.GetProjectSettings(projectId, CancellationToken.None).ConfigureAwait(false));
 }
Пример #7
0
 public async Task <IProjectSettings> GetCurrentProjectSettings(CancellationToken cancellationToken)
 {
     return(await blogRepo.GetProjectSettings("default", cancellationToken).ConfigureAwait(false));
 }