@using Microsoft.AspNetCore.Components.Routing @using Oqtane.Client.Modules.Controls @using Oqtane.Models @using Oqtane.Services @using Oqtane.Modules @using Oqtane.Shared @using Oqtane.Security @inherits ModuleBase @inject IUriHelper UriHelper @inject IPageService PageService @inject IThemeService ThemeService
Cancel @code { public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } string message = ""; Dictionary themes = new Dictionary(); Dictionary panelayouts = new Dictionary(); string name; string path; string parentid; string order = ""; string isnavigation = "True"; string themetype; string layouttype = ""; string icon = ""; string viewpermissions = "All Users"; string editpermissions = "Administrators"; protected override void OnInitialized() { try { themes = ThemeService.GetThemeTypes(PageState.Themes); panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes); } catch (Exception ex) { message = ex.Message; } } private async Task SavePage() { try { Page page = new Page(); page.SiteId = PageState.Page.SiteId; if (string.IsNullOrEmpty(parentid)) { page.ParentId = null; } else { page.ParentId = Int32.Parse(parentid); } page.Name = name; page.Path = path; page.Order = (order == null ? 1 : Int32.Parse(order)); page.IsNavigation = (isnavigation == null ? true : Boolean.Parse(isnavigation)); page.ThemeType = themetype; page.LayoutType = (layouttype == null ? "" : layouttype); page.Icon = (icon == null ? "" : icon); Type type; if (!string.IsNullOrEmpty(layouttype)) { type = Type.GetType(layouttype); } else { type = Type.GetType(themetype); } System.Reflection.PropertyInfo property = type.GetProperty("Panes"); page.Panes = (string)property.GetValue(Activator.CreateInstance(type), null); page.Permissions = UserSecurity.SetPermissions("View", viewpermissions) + UserSecurity.SetPermissions("Edit", editpermissions); await PageService.AddPageAsync(page); PageState.Reload = Constants.ReloadSite; if (PageState.Page.Name == "Page Management") { UriHelper.NavigateTo(NavigateUrl()); } else { UriHelper.NavigateTo(NavigateUrl(path)); } } catch (Exception ex) { message = ex.Message; } } }