@using bitforum.Constants﻿
@using Microsoft.AspNetCore.Identity;
@model List<IdentityRole>
@{
    ViewData["Title"] = "역할 관리";
}

<div class="container">
    <div class="row">
        <div class="col">
            <h3>@ViewData["Title"]</h3>
        </div>
        <div class="col text-end align-self-center">
            <a href="/Director/User" class="btn btn-sm btn-secondary">뒤로가기</a>
        </div>
    </div>
    <hr/>

    <partial name="_StatusMessage" />

    <form method="post" asp-controller="Role" asp-action="Add" accept-charset="utf-8" autocomplete="off">
        <div class="input-group mb-3">
            <label class="input-group-text" for="roleName">Role:</label>
            <input name="role_name" id="roleName" class="form-control" placeholder="역할(Role)을 입력해주세요." />
            <button type="submit" class="btn btn-sm btn-success">역할 추가</button>
        </div>
    </form>

    <div class="table-responsive">
        <table class="table table-bordered table-striped table-hover mt-4">
            <thead>
                <tr class="text-center">
                    <th>ID</th>
                    <th>Role Name</th>
                    <th>Permission</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tbody>
                @if (Model == null || !Model.Any())
                {
                    <tr>
                        <td colspan="4" class="text-center align-middle">No Data.</td>
                    </tr>
                }
                else
                {
                    @foreach (var role in Model)
                    {
                        <tr class="text-center align-middle">
                            <td>@role.Id</td>
                            <td>@role.Name</td>
                            <td>@ViewBag.RoleClaimsCount[role.Name]</td>
                            <td>
                                <a class="btn btn-sm btn-primary" asp-controller="Role" asp-action="ManagePermissions" asp-route-roleID="@role.Id">권한 관리</a>
                            </td>
                        </tr>
                    }
                }
            </tbody>
        </table>
    </div>
</div>