@model IEnumerable<LANCommander.Data.Models.Game>

@{
    ViewData["Title"] = "Games";
}
<div class="container-xl">
    <div class="page-header d-print-none">
        <div class="row align-items-center">
            <div class="col">
                <h2 class="page-title">
                    Games
                </h2>
            </div>

            <div class="col-auto ms-auto">
                <div class="btn-list">
                    <a asp-action="Add" class="btn btn-primary d-none d-sm-inline-block">
                        <svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
                        Add
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="page-body">
    <div class="container-xl">
        <div class="row row-cards">
            <div class="col-12">
                <div class="card">
                    <div class="table-responsive">
                        <table class="table table-vcenter table-mobile-md card-table">
                            <thead>
                                <tr>
                                    <th></th>
                                    <th>
                                        @Html.DisplayNameFor(model => model.Title)
                                    </th>
                                    <th>
                                        @Html.DisplayNameFor(model => model.SortTitle)
                                    </th>
                                    <th>
                                        @Html.DisplayNameFor(model => model.ReleasedOn)
                                    </th>
                                    <th>
                                        @Html.DisplayNameFor(model => model.CreatedOn)
                                    </th>
                                    <th>
                                        @Html.DisplayNameFor(model => model.CreatedBy)
                                    </th>
                                    <th>
                                        @Html.DisplayNameFor(model => model.UpdatedOn)
                                    </th>
                                    <th>
                                        @Html.DisplayNameFor(model => model.UpdatedBy)
                                    </th>
                                    <th></th>
                                </tr>
                            </thead>

                            <tbody>
                                @foreach (var item in Model.OrderBy(g => !String.IsNullOrWhiteSpace(g.SortTitle) ? g.SortTitle : g.Title))
                                {
                                    <tr>
                                        <td>
                                            @if (!String.IsNullOrWhiteSpace(item.Icon)) {
                                                <img src="@Url.Action("GetIcon", "Games", new { id = item.Id })" />
                                            }
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.Title)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.SortTitle)
                                        </td>
                                        <td>
                                            @if (item.ReleasedOn.HasValue)
                                            {
                                                @item.ReleasedOn.Value.ToString("MM/dd/yyyy")
                                            }
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.CreatedOn)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.CreatedBy.UserName)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.UpdatedOn)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.UpdatedBy.UserName)
                                        </td>
                                        <td>
                                            <div class="btn-list flex-nowrap justify-content-end">
                                                <a asp-action="Edit" asp-route-id="@item.Id" class="btn">Edit</a>
                                                <a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger">Delete</a>
                                            </div>
                                        </td>
                                    </tr>
                                }
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>