public ActionResult Create(string id, ProfileViewModel viewModel, FormCollection formCollection) { viewModel.Theme = _themeSettingsService.GetTheme(id); if (!ModelState.IsValid) { var settingsManifest = _themeSettingsService.GetSettingsManifest(id); var form = _settingsFormBuilder.BuildForm(settingsManifest); _settingsFormBuilder.BindForm(form, formCollection); viewModel.SettingsForm = _settingsFormBuilder.BindForm(form, formCollection); return(View(viewModel)); } var profile = new ThemeProfile { Name = viewModel.Name.TrimSafe(), Description = viewModel.Description.TrimSafe(), Theme = id, Settings = ParseThemeSettings(formCollection), IsCurrent = viewModel.IsCurrent }; _themeSettingsService.SaveProfile(profile); _notifier.Information(T("The profile {0} for the {1} theme was succesfully created.", viewModel.Name, viewModel.Theme.Name)); return(RedirectToAction("Edit", new { id = profile.Id })); }
public void ExecuteRecipeStep(RecipeContext recipeContext) { if (!String.Equals(recipeContext.RecipeStep.Name, "ThemeSettings", StringComparison.OrdinalIgnoreCase)) { return; } foreach (var themeElement in recipeContext.RecipeStep.Step.Elements()) { var themeName = themeElement.Attr <string>("Name"); foreach (var profileElement in themeElement.Elements()) { var profileName = profileElement.Attr <string>("Name"); var profile = _themeSettingsService.GetProfile(profileName) ?? new ThemeProfile(); profile.Name = profileElement.Attr <string>("Name"); profile.Description = profileElement.Attr <string>("Description"); profile.Theme = themeName; profile.IsCurrent = profileElement.Attr <bool>("IsCurrent"); profile.Settings = _themeSettingsService.DeserializeSettings(profileElement.Value); _themeSettingsService.SaveProfile(profile); } } recipeContext.Executed = true; }
public override void Execute(RecipeExecutionContext context) { foreach (var themeElement in context.RecipeStep.Step.Elements()) { var themeName = themeElement.Attr <string>("Name"); foreach (var profileElement in themeElement.Elements()) { var profileName = profileElement.Attr <string>("Name"); var profile = _themeSettingsService.GetProfile(profileName) ?? new ThemeProfile(); profile.Name = profileElement.Attr <string>("Name"); profile.Description = profileElement.Attr <string>("Description"); profile.Theme = themeName; profile.IsCurrent = profileElement.Attr <bool>("IsCurrent"); profile.Settings = _themeSettingsService.DeserializeSettings(profileElement.Value); _themeSettingsService.SaveProfile(profile); } } }