@model Library.Domain.Entities.Book
@{ Layout = null; }
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="~/Content/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/bootstrap-theme.min.css" rel="stylesheet" />
    <link href="~/Content/CustomErrorStyles.css" rel="stylesheet" />
    <title>Book editing</title>
</head>
<body>
    <div class="panel">
        <div class="panel-heading"><h3>Editing book - @Model.Name</h3>
        </div>
        @using (Html.BeginForm("Edit", "Book")) {
            <div class="panel-body">
                @Html.HiddenFor(m => m.ID)
                @foreach (var property in ViewData.ModelMetadata.Properties) {
                    if (property.PropertyName != "ID"
                        && property.PropertyName != "IsLent") {
                        <div class="form-group">
                            <label>
                                @property.PropertyName
                            </label>
                            @if (property.PropertyName == "Description") {
                                @Html.TextArea(property.PropertyName, null,
                                    new { @class = "form-control", rows = 6 })
                            }
                            else {
                                @Html.TextBox(property.PropertyName, null,
                                    new { @class = "form-control" })
                            }
                            @Html.ValidationMessage(property.PropertyName)
                        </div>
                    }
                }
                <div class="checkbox">
                    <label>
                        @Html.EditorFor(m => m.IsLent)
                        Book is lent
                    </label>
                </div>
            </div>
            <div class="panel-footer">
                <input type="submit" value="Save" class="btn btn-success" />
                @Html.ActionLink("Cancel", "List", "Book", 
                    new { @class = "btn btn-default" })
            </div>
        }
    </div>
</body>
</html>
