@using Microsoft.AspNetCore.Components.Routing
@using Oqtane.Models
@using Oqtane.Services
@using Oqtane.Modules
@using Oqtane.Shared
@using Oqtane.Client.Modules.Controls
@inherits ModuleBase
@inject IUriHelper UriHelper
@inject IPageService PageService
@inject IThemeService ThemeService
@message
Cancel
@code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
string message = "";
Dictionary themes = new Dictionary();
Dictionary panelayouts = new Dictionary();
int PageId;
string name;
string path;
string parentid;
string order;
string isnavigation;
string themetype;
string layouttype;
string icon;
string viewpermissions;
string editpermissions;
string createdby;
DateTime createdon;
string modifiedby;
DateTime modifiedon;
protected override void OnInitialized()
{
try
{
themes = ThemeService.GetThemeTypes(PageState.Themes);
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
PageId = Int32.Parse(PageState.QueryString["id"]);
Page page = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
if (page != null)
{
name = page.Name;
path = page.Path;
if (page.ParentId == null)
{
parentid = "";
}
else
{
parentid = page.ParentId.ToString();
}
order = page.Order.ToString();
isnavigation = page.IsNavigation.ToString();
themetype = page.ThemeType;
layouttype = page.LayoutType;
icon = page.Icon;
viewpermissions = page.ViewPermissions;
editpermissions = page.EditPermissions;
createdby = page.CreatedBy;
createdon = page.CreatedOn;
modifiedby = page.ModifiedBy;
modifiedon = page.ModifiedOn;
}
}
catch (Exception ex)
{
message = ex.Message;
}
}
private async Task SavePage()
{
try
{
Page page = PageState.Page;
page.PageId = Int32.Parse(PageState.QueryString["id"]);
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.ViewPermissions = viewpermissions;
page.EditPermissions = editpermissions;
await PageService.UpdatePageAsync(page);
PageState.Reload = Constants.ReloadSite;
UriHelper.NavigateTo(NavigateUrl(path));
}
catch (Exception ex)
{
message = ex.Message;
}
}
}