@using Library.Domain.Entities
@model IEnumerable<Book>

@{
    ViewBag.Title = "Books";
}

<div class="panel panel-primary">
    <div class="panel-heading clearfix">
        <div class="pull-right">
            @Html.ActionLink("Add new book", "Create", null,
                new { @class = "btn btn-default" })
        </div>
    </div>
    <div class="panel-body">
        <table class="table table-striped">
            <thead>
                <tr>
                    <td><strong>Name</strong></td>
                    <td><strong>Author</strong></td>
                    <td><strong>Genre</strong></td>
                    <td><strong>Subgenre</strong></td>
                    <td><strong>Is lent?</strong></td>
                    <td></td>
                </tr>
            </thead>
            <tbody>
                @foreach (Book book in Model)
                {
                    <tr>
                        <td>@Html.ActionLink(@book.Name, "Edit", new { bookID = @book.ID })</td>
                        <td>@book.Author</td>
                        <td>@book.Genre</td>
                        <td>@book.Subgenre</td>
                        <td>@book.IsLent</td>
                        <td>
                            @using (Html.BeginForm("Delete", "Book"))
                            {
                                @Html.Hidden("bookID", book.ID)
                                <input type="submit" 
                                       class="btn btn-danger btn-xs"
                                       value="Delete" />
                            }
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
</div>