public virtual ActionResult Index(AdminBasicSettings settings) { if (!ModelState.IsValid) { return(View()); } settingRepository.BlogName = settings.BlogName; settingRepository.BlogDescription = settings.BlogDescription; settingRepository.Theme = settings.Theme; settingRepository.PostsPerPage = settings.PostsPerPage; settingRepository.TimeZone = TimeZoneInfo.FindSystemTimeZoneById(settings.TimeZoneId); settingRepository.Culture = settings.Language; settingRepository.ApplicationInsightsInstrumentationKey = settings.ApplicationInsightsInstrumentationKey; settingRepository.CustomCode = settings.CustomCode; TelemetryConfiguration.Active.DisableTelemetry = string.IsNullOrWhiteSpace(settingRepository.ApplicationInsightsInstrumentationKey); if (TelemetryConfiguration.Active.DisableTelemetry == false) { TelemetryConfiguration.Active.InstrumentationKey = settingRepository.ApplicationInsightsInstrumentationKey; } SetSuccessMessage("Settings saved"); return(RedirectToAction("Index")); }
public ActionResult Index() { string themeDir = Path.Combine(AppContext.BaseDirectory, "Views", "Themes"); var fileThemes = Directory.Exists(themeDir) ? new DirectoryInfo(themeDir).GetDirectories().Select(x => new SelectListItem { Text = x.Name }) : Enumerable.Empty <SelectListItem>(); var themePrefix = "Views_Themes_"; var themePrefixLength = themePrefix.Length; var compiledViewsThemes = CompiledViewsHelper.GetAllViews() .Where(x => x.Name.StartsWith(themePrefix)) .Select(x => x.Name.Substring(themePrefixLength)) .Select(x => x.Contains('_') ? x.Substring(0, x.IndexOf("_")) : x) .Select(x => new SelectListItem { Text = x }).ToList(); AdminBasicSettings viewModel = new AdminBasicSettings { BlogName = settingRepository.BlogName, BlogDescription = settingRepository.BlogDescription, Theme = settingRepository.Theme, Themes = fileThemes.Concat(compiledViewsThemes), PostsPerPage = settingRepository.PostsPerPage, TimeZoneId = settingRepository.TimeZone.Id, TimeZones = TimeZoneInfo.GetSystemTimeZones().Select(x => new SelectListItem { Text = x.DisplayName, Value = x.Id }), Language = settingRepository.Culture, ApplicationInsightsInstrumentationKey = settingRepository.ApplicationInsightsInstrumentationKey, CustomCode = settingRepository.CustomCode, }; return(View(viewModel)); }
public ActionResult Index() { AdminBasicSettings viewModel = new AdminBasicSettings { BlogName = settingRepository.BlogName, BlogDescription = settingRepository.BlogDescription, Theme = settingRepository.Theme, Themes = new DirectoryInfo(Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "Views", "Themes")).GetDirectories().Select(x => new SelectListItem { Text = x.Name }), PostsPerPage = settingRepository.PostsPerPage, TimeZoneId = settingRepository.TimeZone.Id, TimeZones = TimeZoneInfo.GetSystemTimeZones().Select(x => new SelectListItem { Text = x.DisplayName, Value = x.Id }), Language = settingRepository.Culture, ApplicationInsightsInstrumentationKey = settingRepository.ApplicationInsightsInstrumentationKey, CustomCode = settingRepository.CustomCode, }; return(View(viewModel)); }