@page
@model webserver.Pages.Manage.CompanyLIST
@{
    ViewData["Title"] = "CompanyLIST";
}

<h1>@ViewData["Title"]</h1>

<br>
    <h2>Companies List</h2>
    <a class="btn btn-primary btn-sm" href="/Manage/CompanyCreation">Create</a>
    <table class="table">
        <thead>
            <tr>
                <th>
                    <form method="get">
                        <input type="hidden" name="pageIndex" value=@Model.index />
                        <input type="hidden" name="pageSize" value=@Model.size />
                        <input type="hidden" name="orderby" value="UserName" />
                        <button type="submit" class="btn btn-secondary">Name</button>
                    </form>
                </th>
                <th>
                    <form method="get">
                        <input type="hidden" name="pageIndex" value=@Model.index />
                        <input type="hidden" name="pageSize" value=@Model.size />
                        <input type="hidden" name="orderby" value="City" />
                        <button type="submit" class="btn btn-secondary">City</button>
                    </form>
                    </th>
                <th><form method="get">
                        <input type="hidden" name="pageIndex" value=@Model.index />
                        <input type="hidden" name="pageSize" value=@Model.size />
                        <input type="hidden" name="orderby" value="State" />
                        <button type="submit" class="btn btn-secondary">State</button>
                    </form>
                    </th>
                <th><form method="get">
                        <input type="hidden" name="pageIndex" value=@Model.index />
                        <input type="hidden" name="pageSize" value=@Model.size />
                        <input type="hidden" name="orderby" value="Country" />
                        <button type="submit" class="btn btn-secondary">Country</button>
                    </form>
                    </th>
            </tr>
        </thead>
        <body>
            <li class="item">
                @foreach(var item in Model.listComps){
                    <tr>
                        <td>@item.UserName</td>
                        <td>@item.City</td>
                        <td>@item.State</td>
                        <td>@item.Country</td>
                    </tr>
                }
            </li>
        </body>
    </table>
</br>

@{
    int num = (int)Math.Ceiling((float)(Model.rowCount / Model.size)) + 1;
}
<div class="btn-group">
    @for (int i = 1; i <= num && i<10; i++) {
        <form method="get" style="margin-right: 2%;">
            <input type="hidden" name="pageIndex" value="@i" />
            <input type="hidden" name="pageSize" value="5" />
            
            @if(Model.index==i){
                <button type="submit" class="btn btn-success">@i</button>
            }else{
                <button type="submit" class="btn btn-primary">@i</button>
            }
        </form>
    }
</div>