public ActionResult AjoutTheme(AdminViewModels pVm) { if (ModelState.IsValid) { themeService.Create(pVm.MonTheme); } return(RedirectToAction("IndexThemes")); }
private void BtnCreate_Click(object sender, RoutedEventArgs e) { if (txbTheme.Text != string.Empty && txbDescription.Text != string.Empty) { _themeService.Create(new Entities.Theme { Name = txbTheme.Text, Description = txbDescription.Text }); MessageBox.Show("Объект успешно создан!"); Close(); } else { MessageBox.Show("Заполните все ключевые поля!"); } }
protected override void EndProcessing() { var dashboard = new Dashboard(); dashboard.Title = Title; dashboard.NavBarColor = NavBarColor?.HtmlColor; dashboard.NavBarFontColor = NavBarFontColor?.HtmlColor; dashboard.BackgroundColor = BackgroundColor?.HtmlColor; dashboard.FontColor = FontColor?.HtmlColor; dashboard.NavbarLinks = NavbarLinks; dashboard.Scripts = Scripts; dashboard.Stylesheets = Stylesheets; dashboard.CyclePages = CyclePages; dashboard.CyclePagesInterval = CyclePagesInterval; dashboard.Footer = Footer; dashboard.NavBarLogo = NavBarLogo; dashboard.InitializationScript = EndpointInitializationScript?.GenerateCallback("IS", SessionState, false); dashboard.GeoLocation = GeoLocation; if (Theme != null) { var themeService = new ThemeService(); Theme.RenderedContent = themeService.Create(Theme); dashboard.Themes = new [] { Theme }; } else { var themeService = new ThemeService(); var defaultTheme = themeService.LoadThemes().First(m => m.Name.Equals("Default")); defaultTheme.RenderedContent = themeService.Create(defaultTheme); dashboard.Themes = new [] { defaultTheme }; } AddDynamicParameters(dashboard); ValidateModel(dashboard); if (ParameterSetName == "Content") { var page = new Page(); page.Name = "home"; dashboard.Pages.Add(page); try { var components = Content.Invoke(); foreach (var component in components) { var dashboardComponent = component.BaseObject as Component; if (dashboardComponent != null) { page.Components.Add(dashboardComponent); } } } catch (Exception ex) { WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.SyntaxError, dashboard)); dashboard.Error = ex.Message; } } if (ParameterSetName == "Pages") { dashboard.Pages.AddRange(Pages); } Log.Debug(JsonConvert.SerializeObject(dashboard)); WriteObject(dashboard); }
protected override void EndProcessing() { var dashboard = new Dashboard(); dashboard.Title = Title; dashboard.NavBarColor = NavBarColor?.HtmlColor; dashboard.NavBarFontColor = NavBarFontColor?.HtmlColor; dashboard.BackgroundColor = BackgroundColor?.HtmlColor; dashboard.FontColor = FontColor?.HtmlColor; dashboard.NavbarLinks = NavbarLinks; dashboard.Scripts = Scripts; dashboard.Stylesheets = Stylesheets; dashboard.CyclePages = CyclePages; dashboard.CyclePagesInterval = CyclePagesInterval; dashboard.Footer = Footer; dashboard.NavBarLogo = NavBarLogo; dashboard.EndpointInitialSessionState = EndpointInitialization; dashboard.GeoLocation = GeoLocation; dashboard.IdleTimeout = IdleTimeout; dashboard.Navigation = Navigation; if (!AssetService.Instance.Frameworks.ContainsKey(DefaultFramework)) { throw new Exception($"Invalid DefaultFramework specified. Valid frameworks are {AssetService.Instance.Frameworks.Keys.Aggregate((x,y) => x + ", " + y )}"); } dashboard.FrameworkAssetId = AssetService.Instance.Frameworks[DefaultFramework]; if (Theme != null) { var themeService = new ThemeService(); Theme.RenderedContent = themeService.Create(Theme); dashboard.Themes = new [] { Theme }; } else { var themeService = new ThemeService(); var defaultTheme = themeService.LoadThemes().First(m => m.Name.Equals("Default")); defaultTheme.RenderedContent = themeService.Create(defaultTheme); dashboard.Themes = new [] { defaultTheme }; } if (ParameterSetName == "Content") { var page = new Page(); page.Name = "home"; dashboard.Pages.Add(page); try { var components = Content.Invoke(); foreach (var component in components) { if (component.BaseObject is Component dashboardComponent) { page.Components.Add(dashboardComponent); } if (component.BaseObject is Dictionary <string, object> dictionary) { page.Components.Add(new GenericComponent(dictionary)); } if (component.BaseObject is Hashtable hashtable) { page.Components.Add(new GenericComponent(hashtable)); } } } catch (Exception ex) { WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.SyntaxError, dashboard)); dashboard.Error = ex.Message; } } if (ParameterSetName == "Pages") { dashboard.Pages.AddRange(Pages); } Log.Debug(JsonConvert.SerializeObject(dashboard)); WriteObject(dashboard); }
protected override void EndProcessing() { if (EndpointInitialization == null) { EndpointInitialization = UDRunspaceFactory.GenerateInitialSessionState(SessionState); } var dashboard = new Dashboard(); dashboard.Title = Title; dashboard.Scripts = Scripts; dashboard.Stylesheets = Stylesheets; dashboard.EndpointInitialSessionState = EndpointInitialization; dashboard.GeoLocation = GeoLocation; dashboard.IdleTimeout = IdleTimeout; dashboard.Properties = MyInvocation.BoundParameters; if (!AssetService.Instance.Frameworks.ContainsKey(DefaultFramework)) { throw new Exception($"Invalid DefaultFramework specified. Valid frameworks are {AssetService.Instance.Frameworks.Keys.Aggregate((x,y) => x + ", " + y )}"); } dashboard.FrameworkAssetId = AssetService.Instance.Frameworks[DefaultFramework]; if (Theme != null) { var themeService = new ThemeService(); Theme.RenderedContent = themeService.Create(Theme); dashboard.Themes = new [] { Theme }; } else { var themeService = new ThemeService(); var defaultTheme = themeService.LoadThemes().First(m => m.Name.Equals("Default")); defaultTheme.RenderedContent = themeService.Create(defaultTheme); dashboard.Themes = new [] { defaultTheme }; } if (ParameterSetName == "Content") { var page = new Page(); page.Name = "home"; dashboard.Pages.Add(page); try { page.Id = Guid.NewGuid().ToString(); page.Callback = Content.GenerateCallback(page.Id, this, SessionState, new object[0]); page.Callback.IsPage = true; page.Callback.Page = page; page.Dynamic = true; } catch (Exception ex) { WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.SyntaxError, dashboard)); dashboard.Error = ex.Message; } } if (ParameterSetName == "Pages") { dashboard.Pages.AddRange(Pages); } Log.Debug(JsonConvert.SerializeObject(dashboard)); WriteObject(dashboard); }