oqtane.framework/Oqtane.Client/Modules/Admin/Pages/Index.razor
2019-10-22 11:57:28 -04:00

42 lines
1.3 KiB
Plaintext

@namespace Oqtane.Modules.Admin.Pages
@inherits ModuleBase
@inject NavigationManager NavigationManager
@inject IPageService PageService
@if (PageState.Pages != null)
{
<ActionLink Action="Add" Text="Add Page" Style="float: right; margin: 10px;" />
<Pager Items="@PageState.Pages.Where(item => !item.IsDeleted)">
<Header>
<th>Name</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
</Header>
<Row>
<td>@(new string('-', context.Level * 2))@(context.Name)</td>
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.PageId.ToString())" /></td>
<td><button @onclick="@(() => Delete(context))" class="btn btn-danger">Delete</button></td>
</Row>
</Pager>
}
@code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
private async Task Delete(Page Page)
{
try
{
Page.IsDeleted = true;
await PageService.UpdatePageAsync(Page);
NavigationManager.NavigateTo(NavigateUrl("admin/pages", Reload.Site));
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Loading Pages {Error}", ex.Message);
AddModuleMessage("Error Loading Pages", MessageType.Error);
}
}
}