LocalGovIMS_localgov-ims/src/Admin/Views/User/List.cshtml
@model Admin.Models.User.ListViewModel
@{
    ViewBag.Title = "Users";
}

@section Header { Users }

@section Subheader { User management }

@section Actions {
    @Html.ActionLink("Create user", "Create", new { }, new { @class = "btn btn-secondary" })
}

<h3 class="visually-hidden">Search criteria</h3>

<div class="border border-1 rounded p-2">
    @Html.Partial("_Search", Model.SearchCriteria)
</div>

<h3 class="visually-hidden">Search results</h3>

@if (Model.Items != null && Model.Items.Any())
{
    <div class="table-responsive">
        <table class="table table-striped table-bordered table-hover mt-2">
            <thead>
                <tr>
                    <th scope="col">
                        Username
                    </th>
                    <th scope="col">
                        Display name
                    </th>
                    <th scope="col">
                        Status
                    </th>
                    <th scope="col">
                        <span class="visually-hidden">Actions</span>
                    </th>
                </tr>
            </thead>
            @foreach (var item in Model.Items)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(m => item.UserName)
                    </td>
                    <td>
                        @Html.DisplayFor(m => item.DisplayName)
                    </td>
                    <td>
                        @Html.Label(item.Disabled ? "Disabled" : "Active")
                    </td>
                    <td class="text-end">
                        @Html.ActionLink("View", "Details", new { id = item.UserId }, new { @class = "btn btn-secondary" })
                        @if (@User.Identity.Name != @item.UserName || User.IsInRole(Role.SystemAdmin))
                        {
                            @Html.ActionLink("Edit", "Edit", new { id = item.UserId }, new { @class = "btn btn-secondary" })
                        }
                    </td>
                </tr>
            }
        </table>
    </div>
}
else
{
    Html.RenderPartial("_NoResultsMessage", "users");
}

