Example #1
0
        private RepositoryResponse <JObject> GetAllSettings(string lang = null)
        {
            lang ??= MixService.GetAppSetting <string>(MixAppSettingKeywords.DefaultCulture);
            var cultures = CommonRepository.Instance.LoadCultures();
            var culture  = cultures.FirstOrDefault(c => c.Specificulture == lang);

            // Get Settings
            GlobalSettingsViewModel configurations = new GlobalSettingsViewModel()
            {
                Domain = MixService.GetAppSetting <string>(MixAppSettingKeywords.Domain),
                Lang   = lang,
                PortalThemeSettings    = MixService.GetAppSetting <JObject>(MixAppSettingKeywords.PortalThemeSettings),
                ThemeId                = MixService.GetConfig <int>(MixAppSettingKeywords.ThemeId, lang),
                ApiEncryptKey          = MixService.GetAppSetting <string>(MixAppSettingKeywords.ApiEncryptKey),
                IsEncryptApi           = MixService.GetAppSetting <bool>(MixAppSettingKeywords.IsEncryptApi),
                Cultures               = cultures,
                PageTypes              = Enum.GetNames(typeof(MixPageType)),
                ModuleTypes            = Enum.GetNames(typeof(MixModuleType)),
                MixDatabaseTypes       = Enum.GetNames(typeof(MixDatabaseType)),
                DataTypes              = Enum.GetNames(typeof(MixDataType)),
                Statuses               = Enum.GetNames(typeof(MixContentStatus)),
                RSAKeys                = RSAEncryptionHelper.GenerateKeys(),
                ExternalLoginProviders = new JObject()
                {
                    new JProperty("Facebook", MixService.Instance.MixAuthentications.Facebook?.AppId),
                    new JProperty("Google", MixService.Instance.MixAuthentications.Google?.AppId),
                    new JProperty("Twitter", MixService.Instance.MixAuthentications.Twitter?.AppId),
                    new JProperty("Microsoft", MixService.Instance.MixAuthentications.Microsoft?.AppId),
                },
                LastUpdateConfiguration = MixService.GetAppSetting <DateTime?>(MixAppSettingKeywords.LastUpdateConfiguration)
            };

            configurations.LangIcon = culture?.Icon ?? MixService.GetAppSetting <string>(MixAppSettingKeywords.Language);

            // Get translator
            var translator = new JObject()
            {
                new JProperty("lang", lang),
                new JProperty("data", MixService.GetTranslator(lang))
            };

            // Get Configurations
            var localizeSettings = new JObject()
            {
                new JProperty("lang", lang),
                new JProperty("langIcon", configurations.LangIcon),

                new JProperty("data", MixService.GetLocalizeSettings(lang))
            };


            JObject result = new JObject()
            {
                new JProperty("globalSettings", JObject.FromObject(configurations)),
                new JProperty("translator", translator),
                new JProperty("localizeSettings", JObject.FromObject(localizeSettings))
            };



            return(new RepositoryResponse <JObject>()
            {
                IsSucceed = true,
                Data = result
            });
        }