@model ZelWiki.Models.ViewModels.Admin.NamespaceViewModel
@using ZelWiki.Library
@using ZelWiki.Models
@{
    Layout = "/Views/Shared/_Layout.cshtml";
    var sessionState = ViewData["SessionState"] as ZelWiki.SessionState ?? throw new Exception("Wiki State Context cannot be null.");
}

<h3>
    Namespace
</h3>

<p>
    All pages contained in the namespace.<br /><br />
</p>

@if (!string.IsNullOrEmpty(Model.ErrorMessage))
{
    <div class="alert alert-danger">@Html.Raw(Model.ErrorMessage)</div>
}
@if (!string.IsNullOrEmpty(Model.SuccessMessage))
{
    <div class="alert alert-success">@Html.Raw(Model.SuccessMessage)</div>
}

@using (Html.BeginForm(null, null, FormMethod.Get, new { action = $"{GlobalConfiguration.BasePath}{Context.Request.Path}" }))
{
    <table class="table fixedTable100 table-striped" border="0" cellspacing="0" cellpadding="0">
        <thead>
            <tr>
                <td><strong><a href="?@QueryStringConverter.OrderHelper(sessionState, "Name")">Name</a></strong></td>
                <td><strong><a href="?@QueryStringConverter.OrderHelper(sessionState, "Revision")">Revision</a></strong></td>
                <td><strong><a href="?@QueryStringConverter.OrderHelper(sessionState, "ModifiedBy")">Modified By</a></strong></td>
                <td><strong><a href="?@QueryStringConverter.OrderHelper(sessionState, "ModifiedDate")">Modified Date</a></strong></td>
            </tr>
        </thead>

        @foreach (var p in Model.Pages)
        {
            <tr>
                <td><a href="@GlobalConfiguration.BasePath/@p.Navigation">@p.Name</a></td>
                <td><a href="@GlobalConfiguration.BasePath/@p.Navigation/Revisions">@p.Revision</a></td>
                <td>@p.ModifiedByUserName</td>
                <td>@p.ModifiedDate</td>
            </tr>
        }
    </table>

    @Html.Raw(ZelWiki.Library.PageSelectorGenerator.Generate(Context.Request.QueryString, Model.PaginationPageCount))
}
