@page
@using StudentHouseDashboard.Models;
@model WebApp.Pages.AnnouncementsModel
@{
    ViewData["Title"] = "Announcements";
    List<User> users = (List<User>)ViewData["users"];
    int currentPage = @Convert.ToInt32(ViewData["page"]);
}

@foreach (User user in users)
{
    <div class="card" style="display:inline-block; width: 18rem;">
        <div class="card-body">
            <h5 class="card-title">@user.Role.ToString()</h5>
            <h6 class="card-subtitle mb-2 text-muted">@user.Name</h6>
            <p class="card-text">@user.Password</p>
            <a href="./Announcement?id=@user.ID" class="btn btn-primary">More details</a>
        </div>
    </div>
}

<br />

<nav aria-label="Page navigation">
    <ul class="pagination justify-content-center">
        @if (currentPage <= 1)
        {
            @: <li class="page-item disabled">
            @: <a class="page-link" href="./Announcements?p=@(currentPage - 1)" tabindex="-1">Previous</a>
            @: </li>
        }
        else  
        {
            @: <li class="page-item">
            @: <a class="page-link" href="./Announcements?p=@(currentPage - 1)" tabindex="-1">Previous</a>
            @: </li>
            @: <li class="page-item"><a class="page-link" href="./Announcements?p=@(currentPage - 1)">@(currentPage - 1)</a></li>
        }
        <li class="page-item"><a class="page-link">@currentPage</a></li>
        @if (users.Count == 0)
        {
            @: <li class="page-item disabled">
        }
        else  
        {
            @: <li class="page-item"><a class="page-link" href="./Announcements?p=@(currentPage + 1)">@(currentPage + 1)</a></li>
            @: <li class="page-item">
        }
            <a class="page-link" href="./Announcements?p=@(currentPage + 1)">Next</a>
        </li>
    </ul>
</nav>
