@model ZelWiki.Models.ViewModels.Admin.RolesViewModel
@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>
    角色
</h3>

<p>
    <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.Post, new { action = $"{GlobalConfiguration.BasePath}{Context.Request.Path}" }))
{
    @Html.AntiForgeryToken()

    @if (Model.Roles.Count > 0)
    {
        <table class="table fixedTable100 table-striped" border="0" width="100%" cellspacing="0" cellpadding="0">
            <thead>
                <tr>
                    <td><strong><a href="?@QueryStringConverter.OrderHelper(sessionState, "Name")">角色名称</a></strong></td>
                    <td><strong><a href="?@QueryStringConverter.OrderHelper(sessionState, "Description")">描述</a></strong></td>
                </tr>
            </thead>

            @foreach (var role in Model.Roles)
            {
                <tr>
                    <td><a href="@GlobalConfiguration.BasePath/Admin/Role/@role.Name">@role.Name</a></td>
                    <td>@role.Description</td>
                </tr>
            }
        </table>
    }
    else
    {
        <div class="d-flex small text-muted mb-0">
            <strong>
               暂无数据
            </strong>
        </div>
    }
}
