
@{
    ViewData["Title"] = "List";
}

<h1>List</h1>

<form action="/Book/List" method="get">
    <label for="filter">Filter overdue book(s).</label>
    <input type="checkbox" name="filter" @if (ViewBag.Filter == "on") { @("checked") } />
    <button type="submit">Filter</button>
</form>

<table>
    <thead>
        <tr>
            <th>ID</th>
            <th>Title</th>
            <th>Author</th>
            <th>Publication Date</th>
            <th>Checked Out Date</th>
            <th>Due Date</th>
            <th>Returned Date</th>
        </tr>
    </thead>
    <tbody>
        @foreach (Book book in ViewBag.Books)
        {
            <tr>
                <td><a href="/Book/Details?id=@(book.ID)">@(book.ID)</a></td>
                <td>@(book.Title)</td>
                <td>@(book.Author.Name)</td>
                <td>@(book.PublicationDate.ToLongDateString())</td>
                <td>@(book.CheckedOutDate.ToLongDateString())</td>
                <td>@(book.DueDate.ToLongDateString())</td>
                <td>@(book.ReturnedDate==null?"Not Returned":((DateTime)book.ReturnedDate).ToLongDateString())</td>
            </tr>
        }
    </tbody>
</table>